Tuesday, July 22, 2008

Twitter Hello-World: that was easy

I'm working on Twitter integration for Tipjoy. It's going to be all about pushing your favorite content out to your friends on twitter, like our FriendFeed integration.

I just finished a 'hello world' integration. Here is the result.

Here is the code:
#!/usr/bin/python
import urllib
import urllib2
import urlparse
username = "tipjoy"
password = "get.your.own"
realm = "Twitter API"
url = 'http://twitter.com/statuses/update.json'
(scheme, netloc, path, params, query, fragment) = urlparse.urlparse(url)
handler = urllib2.HTTPBasicAuthHandler()
handler.add_password(realm, netloc, username, password)
opener = urllib2.build_opener(handler)
text = "hello from python"
data = {'status': text}
encoded_data = urllib.urlencode(dict([(k, unicode(v).encode('utf-8')) for k, v in data.items()]))
url_data = opener.open(url, encoded_data).read()

7 Comments:

At July 22, 2008 at 4:22 PM , Blogger Andy Weissman said...

Can Switchabit help push from TipJoy to Twitter?

 
At July 22, 2008 at 11:34 PM , Blogger Ivan said...

We have RSS feeds for a user's tips and the top/featured/recent content on Tipjoy. I think there are a half dozen tools that can feed that to twitter.

The actual integration with Twitter is trivial. Just a few lines of code. The harder part is the UI and UX on the feed. I'd like the user to be able to add a message, even after they've tipped. I'd like someone to be able to get an @reply tweet with the message. This needs to be integrated into a new bookmarklet and into the page flow.

If you go to Tipjoy now, under each piece of content, you'll see "comments", "share", "view all", etc. - "twitter" might go on that list.

Switchabit would make sense for a few services though. I need to look into it more. We have bigger plans for facebook than just feeding content. We'll replicate the functionality of tipjoy.com and then some.

Dave Fowler from 8aweek/SocialBrowse and I might be making a django module to do what switchabit does. It will be open source probably. We'd like to make reusable components to feed into other services.

 
At July 29, 2008 at 1:51 PM , Blogger Caleb Elston said...

Very cool, excited to see how you integrate some of the more specific integrations points such as @ replies and the like.

 
At July 29, 2008 at 1:56 PM , Blogger Ivan said...

@caleb I was thinking of using @replies to notify people that they've been tipped, especially if they don't yet have tipjoy accounts.

 
At July 29, 2008 at 3:17 PM , Blogger Caleb Elston said...

@Ivan for non TipJoy users where will you get their twitter username from to send them the message?

 
At July 29, 2008 at 3:21 PM , Blogger Ivan said...

The process to find an owner of a page submitted to tipjoy is largely manual. It'll probably be easier to find a link to a twitter stream than find an email address.

 
At December 28, 2009 at 5:44 PM , Blogger Unknown said...

This comment has been removed by a blog administrator.

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home