用于从stackoverlow获取用户数据的URL和参数值

时间:2016-05-30 07:37:46

标签: arrays oauth access-token stackexchange-api

在stackoverflow中的

(stackexchange api,https://api.stackexchange.com/docs/authentication)它清楚地提到了如何将用户发送到登录页面并从中获取访问令牌,但是没有使用url和参数访问用户数据的详细信息,请帮我找到用stackoverflow从正确的url和参数中获取用户数据的方法,

1.使用这些查询字符串参数

向用户发送https://stackexchange.com/oauth
client_id
scope (details)
redirect_uri - must be under an apps registered domain
state - optional

2.POST(application / x-www-form-urlencoded)以下参数https://stackexchange.com/oauth/access_token

client_id
client_secret
code - from the previous step
redirect_uri - must be the same as the provided in the first step

但是使用此访问令牌获取用户数据的url和参数不可用,

1 个答案:

答案 0 :(得分:0)

你是对的,端点没有很好地记录。

我强烈建议您查看API资源管理器。 例如对于“我”的用户信息: https://api.stackexchange.com/docs/me#order=desc&sort=reputation&filter=!9buxV.Gp.&site=stackoverflow&access_token=YOUROWNACCESSTOKEN&key=YOURAPIKEYIDONTKNOWWHY

  1. 点击“获取令牌”(似乎您已经拥有了访问令牌,仅适用于资源管理器)

  2. 点击“运行”: 您可以在浏览器控制台的“网络”选项卡中调试请求(例如在Safari中:右键单击/复制为卷曲以了解实际情况)

  3. - > stackexchange API的问题在于它似乎无法发送
    Bearer TOKEN - 而您(和API资源管理器)将access_token作为GET参数发送:

    https://api.stackexchange.com/2.2/me?order=desc&sort=reputation&filter=withbody&site=stackoverflow&access_token=YOUROWNACCESSTOKEN&key=YOURAPIKEYIDONTKNOWWHY
    

    site参数选择所需的StackExchange网络的配置文件。

    [{"site":"http://stackoverflow.com","param":"stackoverflow"},{"site":"http://serverfault.com","param":"serverfault"},
    {"site":"http://superuser.com","param":"superuser"},{"site":"http://webapps.stackexchange.com","param":"webapps"},
    {"site":"http://gaming.stackexchange.com","param":"gaming"},{"site":"http://webmasters.stackexchange.com","param":"webmasters"},
    {"site":"http://cooking.stackexchange.com","param":"cooking"},{"site":"http://gamedev.stackexchange.com","param":"gamedev"},
    {"site":"http://photo.stackexchange.com","param":"photo"},{"site":"http://stats.stackexchange.com","param":"stats"},
    {"site":"http://math.stackexchange.com","param":"math"},{"site":"http://diy.stackexchange.com","param":"diy"},
    {"site":"http://gis.stackexchange.com","param":"gis"},{"site":"http://tex.stackexchange.com","param":"tex"},
    {"site":"http://askubuntu.com","param":"askubuntu"}]