• lpleva
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

Hi everyone,

 

I am having trouble getting the code below to work. It's pretty much copy/paste from the examples that SF provides in its documentation, hence my confusion:

 

<?php

define("USERNAME", "");
define("PASSWORD", "");
define("SECURITY_TOKEN", "");

require_once ('http://moneythink.org/apps/soapclient/SforceEnterpriseClient.php');

$mySforceConnection = new SforceEnterpriseClient();
$mySforceConnection->createConnection("http://moneythink.org/apps/soapclient/enterprise.wsdl.xml");
$mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);

$query = "SELECT Id, FirstName, LastName, Phone from Contact";
$response = $mySforceConnection->query($query);

echo "Results of query '$query'<br/><br/>\n";
foreach ($response->records as $record) {
    // Id is on the $record, but other fields are accessed via the fields object
    echo $record->Id . ": " . $record->fields->FirstName . " "
        . $record->fields->LastName . " " . $record->fields->Phone . "<br/>\n";
}

?>

 I am very new to PHP/working with API's, so my apologies if I made any basic mistakes. When I try to execute http://moneythink.org/apps/sf-app.php, which contains the code above, I just get a "Server Error" message. 

  • April 07, 2013
  • Like
  • 0