Question:

How to use python with Twitter?

by Guest2814  |  12 years, 7 month(s) ago

0 LIKES UnLike

The graphic does not show up only a white question mark in a blue box. What am I doing wrong? I have checked the file path and the photo is in the correct folder. How to use python with Twitter?

 Tags: Python, twitter

   Report

1 ANSWERS

  1. Guest4499
    For the sake of example, we’ll use the Python library. Download and install the library and fire up a terminal window.
    Let’s grab your last twenty tweets. Fire up Python and type the following line, replacing “youusername” with your username:
    1
    >>> import twitter
    2

    3
    >>> client = twitter.Api()
    4

    5
    >>> latest_posts = client.GetUserTimeline("yourusername")
    6

    7
    >>> print [s.text for s in latest_posts]
    The last line prints out just the text of your posts. To get at things like date pasted and other useful methods, have a read through the Python library documentation.

    To go the other direction (posting something to Twitter) we’ll need to authenticate. Recreate our Twitter client, but this time pass in your username and password:
    1
    >>> client = twitter.Api(username='yourusername', password='yourpassword')
    2

    3
    >>> update = client.PostUpdate('The Twitter API is easy')
    Head over to your Twitter page and you should see the update.

Sign In or Sign Up now to answser this question!

Question Stats

Latest activity: 13 years, 2 month(s) ago.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.