今天我遇到了一种情况。
我正在使用file_get_contents
从用户文件中获取令牌。
$data=file_get_contents("http://example.com/aaa.php?user=tester&akey=abcdef1234"); $dec=json_decode($data,true); $tokenid=$dec['message']['result']['tokenid'];
使用令牌,我将调用另一个文件以获取详细信息;
$data=file_get_contents("http://example.com/bbb.php?user=tester&token=".$tokenid);
问题是有时我没有得到tokenid,刷新页面后我得到了它。
在aaa.php中没有问题,它的工作正常。
我怀疑php是否file_get_contents
在第二秒之前不等待令牌的响应file_get_contents(asynchronous);
我也尝试过curl,但是有时我没有得到tokenid。我还没有遇到过这类问题。