php curl请求永不结束

时间:2018-07-31 01:09:13

标签: php api curl

我试图从curl调用API,这在postman中工作正常。当在php中运行时,它从未通过curl_exec调用。曾尝试过许多选项并阅读了许多其他文章,但无济于事。

$url = "http://stats.nba.com/stats/scoreboardV2?Season=2017-18&LeagueID=00&GameDate=10/17/2017&dayoffset=0";
//$url= urlencode($url);
$curl = curl_init($url);    // we init curl by passing the url
print("a");
#curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
#curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
#curl_setopt($curl,CURLOPT_POST,false);   // to send a POST request
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_HEADER, 0);
#curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 15);
#curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
#curl_setopt($curl, CURLOPT_TIMEOUT, 30);
#curl_setopt($curl, CURLOPT_HTTPHEADER, array('Expect: 100-continue'));
print("b");
#curl_setopt($curl,CURLOPT_POSTFIELDS,$access_token_parameters);   // indicate the data to send
#curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);   // to return the transfer as a string of the return value of curl_exec() instead of outputting it out directly.
print("c");
#curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);   // to stop cURL from verifying the peer's certificate.
print("d");
$result = curl_exec($curl) or die("cURL Error" . curl_error($curl));   // to perform the curl session
print("e");
curl_close($curl); 

1 个答案:

答案 0 :(得分:0)

您还可以从邮递员那里获取生成的代码。这就是我使用给定URI所获得的,所以让我们尝试一下,让我知道它是否有效?

a_test_3_check