Tuesday, August 31, 2010

python twitter

This post focuses on providing very basic information about twitter client API for python. I have written a python application that retrieves my tweets and submits my tweet after authentication.

you can use normal http python library 'urllib' to achieve this task. for example

conn_string = "http://%s:%s@twitter.com/statuses/update.json" % (usr,pwd)
tweet = urllib.urlencode({"status":tweet})
f = urllib.urlopen(constring, tweet)

or you can use 'twitter' python package provided here http://code.google.com/p/python-twitter/

Following is a very simple code that demostrate my initial use case.

import twitter
import sys


def getTwitterClient(option, args={}):
if ( option == 'simple' ):
return twitter.Api()
else:
return twitter.Api(username=args['username'], password=args['password'])

if ( sys.argv[1]=='simple' ):
username = sys.argv[2]
client = getTwitterClient('simple');
latest_posts = client.GetUserTimeline( username )
#prints your latest posts on twitter
print [x.text for x in latest_posts]

elif ( sys.argv[1] == 'upd' ):
username = sys.argv[2]
passwd = sys.argv[3]
client = getTwitterClient('auth', {'username': username, 'password': passwd})
update = client.PostUpdate('Today, neuGrid first demo went fine.  Our services performed well as expected')
print update


after saving this code in a anyname.py file. you can call it by using following sample commands.
#to retrieve only the posts
python anyname.py simple <USERNAME>

change <USERNAME> with your twitter username.

#to update your twitter status
python anyname.py upd YOUR_USERNAME YOUR_PASSWORD

Saturday, February 23, 2008

Saturday, February 9, 2008

Current Work

Working on Java implementation n testing of dcap, library used for FDT (fast data transfer). Our task is to remove the bugs which are present in current implementation and establish testbed in NIIT (NUST institute of Information Technology, Pakistan).

FDT Client.... (dcapJ)..... ProtocolDoor.... Pool

iCMS - CERN

iCMS, the CMS information Web system which handles the notes, news, agendas and data analysis produced in a collaboration of about 6000 physicists, engineers and technicians. The system is based on modern technologies like web services, RDF, Hibernate etc. It provides automated workflow for CMS notes submitted by physicists or other scientists working in CERN.
visit this following link to explore iCMS.
http://cms.cern.ch/iCMS

Test Post

It is test post on my blog.