【问题标题】:Screenleap returning NULL in phpScreenleap 在 php 中返回 NULL
【发布时间】:2013-11-08 11:52:27
【问题描述】:

我在 screenleap 中创建了开发者帐户并尝试将 screenleap API 集成到我的应用程序中,但是当我尝试由 screenleap 生成的示例请求代码时,它给了我 NULL。

如何在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);

【问题讨论】:

  • 如果你回显$data,你会得到什么? Feeding json_decode() 不正确的数据将返回 NULL。
  • 一个成功的请求将返回一个带有 200 状态码和一个 JSON 对象的响应
  • 你能举一个 JSON 响应的例子吗?

标签: php api curl broadcast screensharing


【解决方案1】:

您的系统默认设置可能不适用于 SSL 证书验证。

您可以尝试关闭验证:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

如果可行,请参阅 http://php.net/manual/en/function.curl-setopt.phphttp://curl.haxx.se/docs/sslcerts.html 了解更多信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-21
    • 2014-03-27
    • 2015-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-04
    相关资源
    最近更新 更多