【发布时间】:2011-04-15 16:05:44
【问题描述】:
谁能给我一个如何访问Halo: Reach stats API的例子
使用 jquery ajax?
这是一个努力:
GetGameHistory(System.String, System.String, System.String, System.String)
此功能用于浏览玩家的游戏历史。
参数
identifier:您的应用程序的标识符字符串。 玩家代号:目标玩家的玩家代号。 variant_class:要获取的游戏变体类。有效值为“Campaign”、>“Firefight”、“Competitive”、“Arena”、“Invasion”、“Custom”。通过“未知”获得所有游戏。 iPage:您想要的结果页面,从第 0 页开始。
返回值 一个 GameHistoryResponse 对象,其中包含符合您指定条件的游戏列表。
示例 http://www.bungie.net/api/reach/reachapijson.svc /player/gamehistory/ {identifier}/{gamertag}/{variant_class_string}/{iPage}
这是我的尝试:
var apikey = 'xxx';
var gamertag = 'The Hailwood';
var variant = 'Competitive';
var page = '0';
var url = 'http://www.bungie.net/api/reach/reachapijson.svc/player/gamehistory/'+apikey+'/'+gamertag+'/'+variant+'/'+page;
$(document).ready(function() {
$.ajax({
url: url,
success: function(data) {
$('#return').html(data);
}
});
});
但是我得到XMLHttpRequest cannot load http://www.bungie.net/api/reach/reachapijson.svc/player/gamehistory/xxx/The%20Hailwood/Competitive/0. Origin http://localhost is not allowed by Access-Control-Allow-Origin.
这是什么意思?
更新:
好的,所以我通过设置适当的权限来修复它。
但现在我收到了来自服务器的 400 响应。
知道是什么原因造成的吗?
更新 2:
API 不可用! 因此它为什么不工作 :(
【问题讨论】:
-
API 现在可以运行了。您将必须重新生成 API 密钥并注册 Bungie Pro 帐户,您的请求将开始工作。如果您需要围绕服务的 C# 包装器,请查看 haloreachapi.codeplex.com。
-
干杯,它的 php 对我来说,但感谢您的提醒。