简体   繁体   English

CURL函数在php中返回null

[英]CURL function returns null in php

I am trying to fetch some data from my zendesk account as follows: 我正尝试从zendesk帐户中获取一些数据,如下所示:

$ch = curl_init();
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_MAXREDIRS, 10 );
        curl_setopt($ch, CURLOPT_URL, "https://testing136.zendesk.com/api/v2/users/me.json");
        curl_setopt($ch, CURLOPT_USERPWD, "mymail@gmail.com/token:apikey");
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
        curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        $output = curl_exec($ch);
        curl_close($ch);
        $decoded = json_decode($output);
        print("Decode ".$decoded);

I have double checked the parameters and data but nothing is returned. 我仔细检查了参数和数据,但未返回任何内容。 I just get Null although I tried to curl in the cmd and it was done successfully. 尽管我尝试在cmd中卷曲,但我还是得到了Null,并且成功完成了。

Any help would be really appreciated. 任何帮助将非常感激。

请加

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

//Just Remove line no. //只需删除行号 267 of application/libraries/REST_Controller.php in Codeigniter Codeigniter中的267 of application / libraries / REST_Controller.php

header('Content-Length: ' . strlen($output)); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM