【问题标题】:Endpoint to fetch Subreddits of a Reddit Account用于获取 Reddit 帐户的 Subreddits 的端点
【发布时间】:2022-01-20 08:12:37
【问题描述】:

我已经针对 Reddit 帐户完成了我的第三方应用程序的 oauth 流程,并且我已经获得了该帐户的访问令牌。

现在我的下一个问题是

如何使用访问令牌获取帐户的子版块

我似乎无法确定终点。

有人知道那个端点吗?

谢谢

【问题讨论】:

    标签: node.js reddit reddit-access-token


    【解决方案1】:

    Reddit OAuth 文档说,对于 /subreddits/mine/(where) 端点,subreddits OAuth 范围是必要的。

    一旦为用户获取了该范围,您就可以使用以下 sn-ps 代码访问该用户的订阅子版块列表:

    View a users subreddits                                                                                 View in Fusebit
      // Demonstrate using snooclient and Fusebit
      const subscriptions = await redditClient.getSubscriptions().fetchAll();
    
      // OR fetch the first page using a raw HTTP request
      // - the User-Agent is necessary, don't forget it!
      const access_token = redditClient.fusebit.credentials.access_token;
      const httpSubs = await superagent.get(
        'https://oauth.reddit.com/subreddits/mine/subscriber')
        .set('Authorization', `Bearer ${access_token}`)
        .set('User-Agent', 'Fusebit Integration');
    
      const length = httpSubs.body.data.children.length;
      ctx.body = {
        usingSnoo: `User has ${subscriptions.length} subreddits`,
        usingHttp: `The first page has ${length} subreddits`,
      };
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-17
      • 1970-01-01
      • 2018-11-18
      • 2017-12-16
      • 2021-04-28
      • 1970-01-01
      • 2014-12-02
      • 2017-12-17
      相关资源
      最近更新 更多