-
- twitter = Twitter("hello@foo.com", "password123")
-
- # Get the public timeline
- twitter.statuses.public_timeline()
-
- # Get a particular friend's timeline
- twitter.statuses.friends_timeline(id="billybob")
-
- # Also supported (but totally weird)
- twitter.statuses.friends_timeline.billybob()
-
- # Send a direct message
- twitter.direct_messages.new(
- user="billybob",
- text="I think yer swell!")
+
+ t = Twitter(
+ auth=OAuth(token, token_key, con_secret, con_secret_key)))
+
+ # Get your "home" timeline
+ t.statuses.home_timeline()
+
+ # Get a particular friend's tweets
+ t.statuses.user_timeline(user_id="billybob")
+
+ # Update your status
+ t.statuses.update(
+ status="Using @sixohsix's sweet Python Twitter Tools.")
+
+ # Send a direct message
+ t.direct_messages.new(
+ user="billybob",
+ text="I think yer swell!")
+
+ # Get the members of tamtar's list "Things That Are Rad"
+ t._("tamtar")._("things-that-are-rad").members()
+
+ # Note how the magic `_` method can be used to insert data
+ # into the middle of a call. You can also use replacement:
+ t.user.list.members(user="tamtar", list="things-that-are-rad")
+
+ # An *optional* `_timeout` parameter can also be used for API
+ # calls which take much more time than normal or twitter stops
+ # responding for some reasone
+ t.users.lookup(
+ screen_name=','.join(A_LIST_OF_100_SCREEN_NAMES), \
+ _timeout=1)
+
+ # Overriding Method: GET/POST
+ # you should not need to use this method as this library properly
+ # detects whether GET or POST should be used, Nevertheless
+ # to force a particular method, use `_method`
+ t.statuses.oembed(_id=1234567890, _method='GET')
+
+ # Send a tweet with an image included (or set your banner or logo similarily)
+ # By just reading your image from the web or a file in a string:
+ with open("example.png", "rb") as imagefile:
+ params = {"media[]": imagefile.read(), "status": "PTT"}
+ t.statuses.update_with_media(**params)
+ # Or by sending a base64 encoded image:
+ params = {"media[]": base64_image, "status": "PTT", "_base64": True}
+ t.statuses.update_with_media(**params)
+
+