[求助] 关于 battlemetrics 的 API 数据接口调用方法,求经验(有偿)

1 月 19 日
 husons
公司一个老网站调用的 battlemetrics 游戏列表 API 不可以用了,网站原先使用的 php 的 file_get_contents(url)直接调用的 battlemetrics 的 api 接口,最近 battlemetrics 接口加了授权认证方式,需要在 headers 里加 Authorization 的用户 token 信息。
---------------------------------------------
小弟之前一直搞前端,对 PHP 不了解,这 2 天尝试使用 ai 写的 curl 进行调用一直报 403 ,请求 V 友给点建议或帮助,被采纳的建议会奉上两百元红包。
---------------------------------------------
详情信息:
1 、API 接口地址: https://api.battlemetrics.com/servers

---------------------------------------------
示例:
$ curl -n https://api.battlemetrics.com/servers
-G \
-d location=47.6140999%2C-122.1966574 \
-d include=serverGroup \
-d filter[search]=PVE \
-d filter[game]=ark \
-d filter[status]=online \
-d filter[countries][]=US \
-d filter[countries][]=CA \
-d filter[maxDistance]=5000 \
-d filter[players][min]=42 \
-d filter[players][max]=42 \
-d filter[features][469a1706-c8be-11e7-9d7a-e3ed64915530]=true \
-d filter[features][11bc8572-ca45-11e7-bad6-2f023a014d57][or][]=1a7c6614-ca45-11e7-84a2-8b4c8bd3712b \
-d filter[features][11bc8572-ca45-11e7-bad6-2f023a014d57][or][]=1abb5fb8-ca45-11e7-858b-affed11cb7fd \
-d filter[rcon]=true \
-d filter[favorites]=true \
-d filter[groups]=example \
-d filter[groupLeader]=true \
-d filter[ids][whitelist]=123 \
-d filter[ids][blacklist]=123 \
-d filter[organizations]=123 \
-d page[size]=42 \
-d page[key]=100 \
-d page[offset]=50 \
-d page[rel]=next \
-d sort=example \
-d fields[server]=name%2Cip%2Cport \
-d relations[server]=a%2Cb
-----------------------------------------
2 、API 调用说明文档: https://www.battlemetrics.com/developers/documentation
3 、说明:接口地址和文档需要梯子查看,接口调用需要创建账号申请 token,对于 sever 接口不清楚是否需要开通收费服务权限。
4 、本人微信号:husonz
1199 次点击
所在节点    外包
2 条回复
johnawesome172
1 月 19 日
你这个 endpoint 还是可以直接打开啊,点进去就出现 json 了。

如果真有问题就去注册一个新账号,申请一个 authorization token:

Authorization
OAuth 2.0 Bearer tokens are used for authorization. You may create personal access tokens from the developers area.

The Authorization header should be included in all requests.
husons
1 月 19 日
问题原因已经排查出来,主要还是授权和调用次数限制,感谢 V 友们的支持,本帖终结。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1186678

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX