Reputation: 33
I have to integrate with the CRM our company is using, Snapforce CRM. I am just trying to pull data using the example code they have on their documentation but it's returning an error:
Error: Cannot create object
The example script I copied is directly from their api documentation.
This is my script so far, I copied it almost exactly as they have it.
$url = 'https://crm.snapforce.com/vintage/sf_receive_request.inc.php';
$curl = curl_init($url);
$fetchRecords = "format=xml&api_user=$api_user&api_key=$api_key&module=Leads&status=Active&method=fetchRecords";
curl_setopt($curl, CURLOPT_FAILONERROR, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 5);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POST_FIELDS, $fetchRecords);
$r = curl_exec($curl);
curl_close($curl);
libxml_use_internal_errors(true);
$xml = simplexml_load_string($r) or die("Error: Cannot create object");
foreach ($xml as $xml1) {
echo $xml1->lead_id."\n";
echo $xml1->type."\n";
echo $xml1->website."\n";
echo $xml1->contact_first."\n";
}
Is this a problem with how I am trying to loop through the object or am I missing a setopt with CURL maybe? Any advice would be greatly appreciated.
Upvotes: 3
Views: 57
Reputation: 605
CURLOPT_POST_FIELDS is not a valid option, it is CURLOPT_POSTFIELDS.
Upvotes: 1