Skip to content

Commit

Permalink
Fixed url encoding issues when POSTing to twitter
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-martin committed Oct 18, 2010
1 parent 437e662 commit df96f05
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import httplib2

import urllib

import twitter_settings

def get_mentions(since=-1):
Expand Down Expand Up @@ -53,12 +55,12 @@ def get_timeline_tweets_since(since_id=-1):

def post_tweet(text):
client = oauth.Client(twitter_settings.consumer, twitter_settings.token)
resp, content = client.request("https://api.twitter.com/1/statuses/update.json", "POST", "status=" + text)
resp, content = client.request("https://api.twitter.com/1/statuses/update.json", "POST", urllib.urlencode([("status", text)]))

return content

def follow_user(screen_name):
client = oauth.Client(twitter_settings.consumer, twitter_settings.token)
resp, content = client.request("https://api.twitter.com/1/friendships/create.json", "POST", "screen_name=" + screen_name)
resp, content = client.request("https://api.twitter.com/1/friendships/create.json", "POST", urllib.urlencode([("screen_name", screen_name)]))

return content

0 comments on commit df96f05

Please sign in to comment.