Twitter App With Python Requests Libraries

Hello Friends,I am back again with some interesting and exiting code with Python Twitter App.Hope you people are enjoying our Tutorial, if you feel that any of our article or points are not up to mark, please feel free to comment and we will be extremely happy to work on it to improve.

Let begin with today topic of discussion,in this article we will learn about the usage of Twitter API’s. Yes, Twitter API’s you heard it right and it’s really exiting to play with it as well as we can integrate this code in any of our applications.

Connect your Twitter App With Python using Requests Libraries

I know that the UI part of Twitter interaction is much interesting and fascinating, but if you are into python programming world then you would certainly want to know python-way-of-interacting-with-Twitter. Python provides “ Requests ” libraries that provide the interaction among any Apis. The most efficient one are in this article i will cover the concepts of interaction with twitter Api.

Follow the step

  1. Create twitter aap using your twitter account,first sign in to https://twitter.com/,then go to https://dev.twitter.com/
  2. Click on Developer –> Documentation –> Manage My Apps
  3. If you already have an app created then use it,otherwise create new app.
  4. If you selected create new aap ,then fill the form as given below .
  • Name :” whatever you want”
  • Description:” whatever you want”
  • website: http://localhost.com [Note:As we are using for practice purpose so we have to write localhost]
  • callback URL: http://localhost.com
  1. Then go to “Keys and Access Token”tab and click on Create my access token
  2. open terminal and install Requests by typing –> sudo pip install requests
  3. Now create python file in your Desktop as show in below image
  4. Twitter App
  5. Replace Consumer Key(Api key) ,Consumer Secret(Api Secret),Access Token,Access Token Secret with your values as mention in your twitter app and save it as python_twitter.py [you can name it whatever you want]
  6. Now open terminal, change the directory where your python_twitter.py file is,in my case its in Desktop,so–> cd Desktop
  7. Then type fallowing command–> python python_twitter.py
  8. You will get the output of your profile in jason format,as mention in twitter
  9. You can replace the url to see various output.just go to https://dev.twitter.com/ then goto –> Developer –> Documentation –> Rest Apis
  10. You will get the list of Rest Apis, choose one of this by clicking on it, then copy Resource url into your script url variable and save the file and run it in your terminal

For more details on Request module you can visit http://docs.python-requests.org/en/latest/

Hope guys you will understand the concept of Twitter App With Python clearly.Try to implement it with more code,and if you find any difficulty, feel free to drop a comment on this post.

One Response

  1. Olu March 21, 2016