Neha Neha - 27 days ago 6
PHP Question

Screenleap returning NULL in php

I have created developer account in screenleap and trying to integrate screenleap API into my application, but when I am trying sample request code generated by screenleap it is giving me NULL.


How to test sample request in php?

$url = 'https://api.screenleap.com/v2/screen-shares';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('authtoken:my_authtoken'));
curl_setopt($ch, CURLOPT_POSTFIELDS, 'accountid=my_accountid');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);
$json = json_decode($data,true);
var_dump($json);



Answer

It's possible your system defaults aren't working for the SSL certificate verification.

You can try turning off the verification with:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

If that works, see http://php.net/manual/en/function.curl-setopt.php and http://curl.haxx.se/docs/sslcerts.html for more information.