简体   繁体   中英

GET request with authorization header (with httparty or faraday)

I'm tring to use twitter api to fetch some data (Since https://github.com/sferik/twitter is not updaded anymore, some field that I need is left out)

I can get Postman working with fields that I defined, ie, authorization with Oauth 1.0, consumer key and consumer secret.

在此处输入图片说明

My question: how to define these params in Ruby? using HTTParty or Faraday is fine.

I can only get something like this

  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

and after searching around I only find example using oauth 2.0 (like in https://github.com/lostisland/faraday_middleware/wiki/Oauth )


UPDATE

The code from Postmand does not have anything with authorization. Did I miss anything?

在此处输入图片说明

在生成的代码片段窗口中,单击设置图标并启用第一个选项(包括临时标题)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM