Charl van Niekerk » Blog

Main

Latest

Archives

Powered by Blogger

Plurk Python Post Script

Neville Newey of muti wrote the following Python script similar in function to the PHP script I wrote a bit earlier today. Essentially it lets you post a new message to your plurk account.

import urllib
import urllib2
import cookielib

# Based on Charl VN's PHP Code

PLURK_LOGIN_URL = 'http://www.plurk.com/Users/login'
PLURK_ADD_URL = 'http://www.plurk.com/TimeLine/addPlurk'
NICKNAME = 'yourname'
PASSWORD = 'secret'

if __name__ == '__main__':
    # Set up 
    jar = cookielib.CookieJar()
    handler = urllib2.HTTPCookieProcessor(jar)
    opener = urllib2.build_opener(handler)
    
    # Login phase ...
    url = PLURK_LOGIN_URL
    values = { 'nick_name': NICKNAME, 'password': PASSWORD }
    data = urllib.urlencode(values)
    req = urllib2.Request(url, data)
    response = opener.open(req)

    # Now plurk something!
    values = {'content': 'Plurking from Python!', 'lang':'en', 'no_comments':'0'}
    data = urllib.urlencode(values)
    data+='&qualifier=%3A'  # Dont know if this is needed 
    url = PLURK_ADD_URL
    req = urllib2.Request(url, data)
    response = opener.open(req)
    print response.read()

This is the base for a new hook script so that you can now follow muti on plurk!

5 Comments

Comment by Blogger Jason M. Adams on Friday, June 06, 2008 6:10:00 AM

Good work on that snippet! I incorporated it into my plurks-to-tweets code so that now you can synchronize your twitter and plurk accounts: http://mendicantbug.com/2008/06/06/plurk-your-tweets/

Comment by Blogger Jason M. Adams on Friday, June 06, 2008 6:10:00 AM

Woops, the clickable link:

Comment by Blogger Charl van Niekerk on Saturday, June 07, 2008 4:02:00 PM

Cool thanks man. I will check your script out some time as soon as I have a few minutes.

Comment by Blogger wow gold on Monday, June 09, 2008 3:43:00 AM

WOW Gold - wow gold - wow gold online kaufen bei .wow gold..kz

Comment by Blogger David Blume on Monday, July 14, 2008 8:34:00 PM

There's a Python port of the Unofficial Plurk API being made over at Google Code.

http://code.google.com/p/plurkapipy/

Post a Comment

Copyright © 2004-2008 Charl van Niekerk. All articles are released under the Creative Commons Attribution 2.5 South Africa licence, unless where otherwise stated.