php - 在 PHP 中调用 API GET 请求后没有响应
问题描述
好的,所以我一直在开发这个从 API 获取数据的应用程序,我一直在用 PHP 对其进行编码,但我最近遇到了一个错误。我没有得到任何回应
我从在线博客获得了脚本,因为我以前没有使用 cURL 的经验
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Authorization: xxxx',
'Content-Type: application/json',
));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// EXECUTE:
$result = curl_exec($curl);
if(!$result){die("Connection Failure");}
curl_close($curl);
return $result;
$get_data = callAPI('GET', 'https://api.brawlapi.cf/v1/player?tag=Y2QPGG', false);
$response = json_decode($get_data, true);
$errors = $response['response']['errors'];
$data = $response['response']['data'][0];
解决方案
推荐阅读
- c++ - 获取 [e][wifigeneric.cpp:739] hostbyname(): 执行 POST 请求时 dns 失败
- python - 使用python3枕头为gif添加水印,但背景颜色改变了
- pandas - Pandas Groupby 加权标准差
- django - 使用 Django Viewset 中的嵌套子查询和注释对子模型的值求和
- postman - “类型”对象不是可迭代的 drf
- javascript - Reactjs if 条件
- android-recyclerview - 单击 recyclerview 行时,微调器选择的值返回到旧值
- sql - 如何在 SQL 中将调整因子应用于股票价格?
- authentication - 为什么 laravel 中间件实现了 web.php 中的所有路由
- c++ - OpenMP - 预计数据竞争情况但实际上并未发生