cURL请求从imgur api获得NULL响应

Dav*_*hen 2 php api xampp curl imgur

    $image = file_get_contents($_FILES['upload']['tmp_name']);
    $id = 'myid';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://api.imgur.com/3/image.json');
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Authorization: Client-ID ' . $id));
    curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'image' => base64_encode($image) ));
    $response = curl_exec($ch);
    curl_close($ch);
    $response = json_decode($response);
Run Code Online (Sandbox Code Playgroud)

这是我必须将匿名图片上传到imgur的引用块.它适用于我的mac os机器上的xampp,但它不能在我的Windows上使用xampp.我也知道关于windows xampp卷曲的以下内容:

-it is enabled
-it works when i try to grab the content of an url
-it doesnt work when i try to make DELETE request to remove an anonymous image(the same code works on the mac os xampp)
Run Code Online (Sandbox Code Playgroud)

我想两台计算机上的cURL设置有一些差异.如果你能告诉我方法,我将不胜感激!提前致谢.

Jen*_*och 6

这是一个SSL问题.请在curl_exec通话前尝试以下话说

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
Run Code Online (Sandbox Code Playgroud)

(您可以添加var_dump($response);以查看服务器响应.)