0

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, i.e., authorization with Oauth 1.0, consumer key and consumer secret.

enter image description here

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?

enter image description here

ZK Zhao
  • 19,885
  • 47
  • 132
  • 206
  • 1
    Click the "Code" link in your screenshot (directly below the Save button). Then click `Ruby > NET::Http`. Then research how to convert a net/http call to HTTParty or Faraday. – anothermh Jan 26 '20 at 20:20
  • @anothermh could you see my update? There is no authorization in the code generated. Did I miss anything? – ZK Zhao Jan 27 '20 at 00:34
  • What does "Preview Request" on the left side give you? – anothermh Jan 29 '20 at 01:33

1 Answers1

0

In the generated code snippets window, click the setting icon and enable the first option (Include Temporary Header)