Search code examples
apicurltwitter

How to make Twitter API call through curl in unix


I would like to pull the data from Twitter REST API. I have created the consumer key, secret and Access token, secret. I have tried with "Test OAuth", it generates a CURL command but if I change any one parameter then it is giving the below error. Message: {"errors":[{"code":32,"message":"Could not authenticate you."}]}

Now I would like to call the twitter API using CURL in shell script for different screenNames.

I want a sample command some thing like mentioned below

curl --get 'https://api.twitter.com/1.1/statuses/user_timeline.json' --data 'count=2&screen_name=aswin' APIKEY:"xxxxxx",Acesstoken:"yyyyyyyy"

Thanks in advance.

Regards, Aswin


Solution

  • Because most twitter requests require calculating the oauth signature, you should either write a client yourself or reuse an existing command line client.

    1. https://github.com/twitter/twurl
    2. https://github.com/sferik/t
    3. https://github.com/yschimke/oksocial/wiki (Mac focused/cross service)

    As you saw any change to the request will generally invalidate the query, and even time is one of the inputs.