husons
V2EX  ›  外包

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

  •  
  •   husons · Jan 19 · 1574 views
    This topic created in 294 days ago, the information mentioned may be changed or developed.
    公司一个老网站调用的 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
    2 replies  •  2026-01-19 22:03:05 +08:00
    johnawesome172
    1
    你这个 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
    husons
    OP
    Jan 19 via Android
    2
    问题原因已经排查出来,主要还是授权和调用次数限制,感谢 V 友们的支持,本帖终结。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1044 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 18:23 · PVG 02:23 · LAX 10:23 · JFK 13:23
    ♥ Do have faith in what you're doing.