首页 > 解决方案 > Dsetiny2 API,PHP OAuth 身份验证访问令牌无响应

问题描述

我尝试使用https://github.com/Bungie-net/api/wiki/OAuth-Documentation的“访问令牌请求”中描述的内容进行 POST ,但没有响应。为什么。

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.bungie.net/Platform/App/OAuth/Token/ HTTP/1.1?client_id=12345&grant_type=authorization_code&code=".$_GET['code']);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
$json = json_decode(curl_exec($ch));
curl_close($ch);

echo('<pre>');
var_dump($json);
echo('</pre>');
?>

$ _GET ['code'] 是对通过 OAuth 身份验证重定向的 URL 的查询。

标签: php

解决方案


推荐阅读