file_get_contents同步或异步

 幸福得味道2011_122 发布于 2023-01-20 17:19

今天我遇到了一种情况。

我正在使用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。我还没有遇到过这类问题。

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有