我正在执行此卷曲帖子,如下所示:
//set POST variables
$url = 'https://api.vineapp.com/users/authenticate';
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, 'username=email@example.com&password=password');
//execute post
$result = curl_exec($ch);
print_r(curl_getinfo($ch));
//close connection
curl_close($ch);
print_r($response);
在使用mamp在我的本地计算机上运行时,它会成功返回,并带有如下所示的json字符串:
{"code": "", "data": {"username": "InstaBrand", "edition": "US", "userId": 1123456, "key": "key-value-string", "avatarUrl": "http://v.cdn.vine.co/r/avatars/21F43610771076328335136776192_263ec9b0577.0.2.jpg?versionId=nWh0YVdjXW2oxz0P7dild3Q5A4D5M53G"}, "success": true, "error": ""}
运行curl_getinfo
时会显示以下信息:
Array
(
[url] => https://api.vineapp.com/users/authenticate
[content_type] => application/json
[http_code] => 200
[header_size] => 260
[request_size] => 197
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 1.105723
[namelookup_time] => 0.486254
[connect_time] => 0.620647
[pretransfer_time] => 0.925538
[size_upload] => 55
[size_download] => 333
[speed_download] => 301
[speed_upload] => 49
[download_content_length] => 333
[upload_content_length] => 55
[starttransfer_time] => 1.10562
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => 23.21.154.247
[certinfo] => Array
(
)
[primary_port] => 443
[local_ip] => 192.168.15.128
[local_port] => 57522
)
但是,当我在我的服务器上执行此操作时,它会返回500 错误,并且此信息会从curl_getinfo
返回:
Array
(
[url] => https://api.vineapp.com/users/authenticate
[content_type] => text/html
[http_code] => 500
[header_size] => 131
[request_size] => 197
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 2.049556
[namelookup_time] => 0.017791
[connect_time] => 0.019114
[pretransfer_time] => 0.047803
[size_upload] => 55
[size_download] => 87
[speed_download] => 42
[speed_upload] => 26
[download_content_length] => -1
[upload_content_length] => 0
[starttransfer_time] => 2.049474
[redirect_time] => 0
[certinfo] => Array
(
)
)
完成故障排除:
timeout
,curl connectiontimeout
和php max execution time
有足够的时间有没有人知道为什么会发生这种情况,或者在不同的环境中遇到过类似的问题?