2

I am trying to fetch some data from my zendesk account as follows:

$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.

Any help would be really appreciated.

4

2 に答える 2

3

追加してください

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
于 2014-10-23T10:36:40.443 に答える
0

//行番号を削除するだけです。Codeigniter の application/libraries/REST_Controller.php の 267

header('Content-Length: ' . strlen($output)); 
于 2016-03-28T13:30:42.137 に答える