API GET请求后无响应用PHP调用

时间:2019-09-01 17:22:50

标签: php api http curl 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];

我使用的API是https://docs.brawlapi.cf/#/endpoints/player

0 个答案:

没有答案