function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TheBombTheBomb 

PHP CLI not working?

I have written some code to select some custom objects in php from a web page and thought I might use the same code to perform the same operation using cli php...but it doesn't work. For some reason, the query returns a SOAP error message without any message in it! Maybe this is a SOAP issue.

I'm using nusoap/debian/php/linux and a developement sforce application while I am prototyping some functionality.

Sample code is:

require_once("SalesforceClient.php");
$client = new SalesforceClient();
$result = $client->login(XXX,YYY);
if (PEAR::isError($result)) {
$errors = "Error: " . $result->getMessage() . "\n";
} else {
$client = new SalesforceClient($result->sessionId);
$client->_endpoint = $_COOKIE['sf_endpoint'];
$query_str = "select Description, CaseNumber from case ";
$results = $client->query($query_str);
# print_r($result);
if (PEAR::isError($results)) {
print "\n----ERROR\n".$results->getMessage()."\n";
print "$query_str\n\n";
exit;
} else {
foreach ($results as $result) {
print_r($result);
}
}
}
?>
TheBombTheBomb
Just noticed that I am stupid...wrong line was:

$client->_endpoint = $_COOKIE['sf_endpoint'];

which should read

$client->_endpoint = $result->serverUrl;

Serves me right for copying and pasting from an example without understanding.