【发布时间】:2020-01-26 14:20:35
【问题描述】:
我正在尝试使用 twitter api 来获取一些数据(由于 https://github.com/sferik/twitter 不再更新,我需要的一些字段被省略了)
我可以让 Postman 使用我定义的字段,即 Oauth 1.0 授权、消费者密钥和消费者秘密。
我的问题:如何在 Ruby 中定义这些参数?使用 HTTParty 或 Faraday 就可以了。
我只能得到这样的东西
url = 'https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=balajis&exclude_replies=true&include_rts=false&count=100&tweet_mode=extended&trim_user=true'
xml = HTTParty.get(url,
headers: {"Authorization" => "???"}).body
在四处搜索后,我只找到了使用 oauth 2.0 的示例(如https://github.com/lostisland/faraday_middleware/wiki/Oauth)
更新
Postmand 的代码没有任何授权。我错过了什么吗?
【问题讨论】:
-
单击屏幕截图中的“代码”链接(直接在“保存”按钮下方)。然后点击
Ruby > NET::Http。然后研究如何将 net/http 调用转换为 HTTParty 或 Faraday。 -
@anothermh 你能看到我的更新吗?生成的代码中没有授权。我错过了什么吗?
-
左侧的“预览请求”给你什么?