Search code examples
pythontwitterpython-twitter

How to send a Twitter request from Python


So i've been using www.hurl.it to send some twitter app authenticated GET requests. Like this..

https://api.twitter.com/1.1/followers/ids.json?cursor=-1&screen_name=userfoo

Then I put in my user keys and tokens and it sends this request

https://api.twitter.com/1.1/followers/ids.json?cursor=-1&oauth_nonce=***********&screen_name=userfoo&oauth_timestamp=**********&oauth_signature=***********=&oauth_token=**********&oauth_consumer_key=**********&oauth_signature_method=HMAC-SHA1&oauth_version=1.0

So I know a little basic python and I would like to know the most simple way of doing this in python without any library. I just want to send a one time request. Something like this.

>>>import requests
>>>r = requests.get("http://example.com/foo/bar")
>>>print r.status_code
>>>print r.headers
>>>print r.content

So the GET request that needs to be sent have "oauth_nonce", "oauth_signature" and "oauth_timestamp" values. How do I go about getting these values? I would like to do it without any additional libraries. If it is not possible to do it without additional libraries let me know of another way. But I don't know to much about python so it will have to be explained very well.

Thanks


Solution

  • So I used the Tweepy library instead. It seems to be working fine.