11

I have a problem to get the data using curl operation. Here i hide the token, If i use the url only in my browser then it returns the data but here its null.

<?php 
$token = "TOKEN"; //the actual token hidden
$url = "https://crm.zoho.com/crm/private/xml/Leads/getRecords?authtoken=".$token."&scope=crmapi";
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);

$result = curl_exec($ch);
curl_close($ch);
echo $result; //does not return anything
?>

Where i do mistake please help me.

3 Answers 3

17

This is how you can try with CURLOPT_RETURNTRANSFER which is used to return the output and curl_errno() to track the errors :

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, "http://example.com/my_url.php" ); 
curl_setopt($ch, CURLOPT_POST, 1 ); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
$postResult = curl_exec($ch); 

if (curl_errno($ch)) { 
   print curl_error($ch); 
} 
curl_close($ch); 

Helpful Links: curl_errno(), curl_error()

2
  • After i use this code i get: "SSL certificate problem: unable to get local issuer certificate"
    – MuteX
    Mar 23, 2015 at 5:35
  • It return some o my all data, It return only the numbers not the stirngs.
    – MuteX
    Mar 23, 2015 at 6:12
0

Try adding these lines:

<?php 
$token = "TOKEN"; //the actual token hidden
$url = "https://crm.zoho.com/crm/private/xml/Leads/getRecords";
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
    curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array("authtoken"=>$token,"scope"=>"crmapi"));
$result = curl_exec($ch);
curl_close($ch);
echo $result; //does not return anything
?>
0
0

please see below article , not just turn off verify , you should update your php.ini with pem file

https://snippets.webaware.com.au/howto/stop-turning-off-curlopt_ssl_verifypeer-and-fix-your-php-config/

Anyone running a recent Linux distribution is probably already OK, because they get the curl libraries bundled in through their package managers and recent curl libraries come with the latest CA root certificate bundle from Mozilla.org.

For a PHP installation that doesn’t come with this file, like the Windows PHP distribution, you need to download the CA root certificate bundle and tell PHP where to find it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.