【发布时间】:2016-07-28 05:26:34
【问题描述】:
我正在尝试学习如何与非官方的 xbox api (xboxapi.com) 进行交互,但我似乎无法弄清楚如何使用它。文档非常稀缺。这是我最近(也是我认为最好的)尝试。
<?php
$gamertag = rawurlencode("Major Nelson");
$ch = curl_init("http://www.xboxapi.com/v2/xuid/" . $gamertag);
$headers = array('X-Auth: InsertAuthCodeHere', 'Content-Type: application/json');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 ); # return into a variable
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers ); # custom headers, see above
$xuid = curl_exec( $ch ); # run!
curl_close($ch);
echo $xuid;
?>
运行上述内容后,我得到“301 永久移动”。谁能看到我做错了什么?谢谢。
【问题讨论】:
-
所有示例似乎都是
https -
@RamRaider 这是一个很好的观察结果,但即使将其更改为 https 后仍然无法正常工作。
-
你试过
https://xboxapi.com/v2/accountXuid/而不是http://www.xboxapi.com/v2/xuid/吗?似乎最接近 -
@RamRaider accountXuid 用于返回我已链接到 API 的个人 Xbox 帐户的 XUID。
-
哦,是的 - 我现在在文档中看到了端点。使用
https://xboxapi.com/v2/xuid/Major%20Nelson给了我一个关于No API Key provided or invalid API Key的错误