Php 请求不适用于特定URL?
我正在执行此curl post,如下所示:Php 请求不适用于特定URL?,php,curl,vine,Php,Curl,Vine,我正在执行此curl post,如下所示: //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)
//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返回:
故障排除完成:
将服务器上请求的URL更改为其他HTTPS URL=成功响应
确保两个环境运行相同的php版本
确保php和curl超时、curl connectiontimeout和php最大执行时间有足够的时间
有人知道为什么会发生这种情况,或者在不同的环境中有类似的问题吗?您的服务器可以在远程服务器上被禁止吗?您的服务器是否有使用https协议的安全证书设置?Cheery,我不认为是因为它以前从未向该api发出过一个成功的请求。。Larry,至于安全证书,它没有这个设置,但是它能够向其他https服务器(如facebook、google等)发出api请求。
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
(
)
)