You need to sign in to do that
Don't have an account?

Trouble with basic toolkit example
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.
Have you made any progress with this?
One problem is that you are mixing the Enterprise and Partner access methods. If you are using the Enterprise WSDL then there is no fields array; you fields are defined at the top level. You would access $record->FirstName, not $record>fields->FirstName.
Without the error that's being thrown (look in your server error log or PHP log) it's impossible to know what else might be a problem.
If you have already resolved the problem please post the solution.
Park