Ping Rejaw
A very quick and dirty Python CGI script to update Rejaw from Ping.fm via Ping's "Custom URL" service (no longer needed, since Ping.FM supports Rejaw as of 15 Aug 2008)
ping_rejaw.py
—
Python Source,
1Kb
File contents
#!/bin/env python
# ping_rejaw.py
# A very quick and dirty Python CGI script to update Rejaw from Ping.fm via
# Ping's "Custom URL" service.
#
# requires simplejson: http://code.google.com/p/simplejson/
#
# Just put this script somewhere in your website directory structure, make
# it executable, adjust the shebang on line 1 if necessary, edit the
# USERNAME, APIKEY, EMAIL, and PASSWORD variables, then give Ping.FM the
# URL to the script.
#
# Don't share the URL! It will post anything given to it! :)
#
# Also, since your password is in there, do whatever you need to do to
# protect the script from prying eyes.
#
# Get your Rejaw API key at http://rejaw.com/developer/apps
#
# Info re: Ping.fm custom URLs http://ping.fm/custom/help/
import cgi, urllib2, simplejson
USERNAME = 'your_username' # rejaw user name
APIKEY = 'a1b2c3d4e5' # rejaw API key
EMAIL = 'you@domain.com' # email address you gave rejaw
PASSWORD = 'your_password' # rejaw password
def get_response(url):
response = simplejson.loads(urllib2.urlopen(url).read())
return response
def get_session_id():
url = 'http://api.rejaw.com/v1/session/create.json?api_key=%s' % APIKEY
response = get_response(url)
return response['session']
def authenticate(sess):
url = 'http://api.rejaw.com/v1/auth/signin.json?session=%s&email=%s&password=%s' \
% (sess, EMAIL, PASSWORD)
response = get_response(url)
return response
def shout(sess):
form = cgi.FieldStorage()
msg = form['message'].value
msg = urllib2.quote(msg)
url = 'http://api.rejaw.com/v1/conversation/shout.json?session=%s&text=%s' \
% (sess,msg)
response = get_response(url)
return response['status']
sess = get_session_id()
authenticate(sess)
print "Content-Type: text/plain"
print
print shout(sess)



