django + blip.pl: automatic new statuses
January 12, 2010 | pythonauthor: Karol Zielinski | comments: 5 | views: 1859
Tags: blip, django, microblogging, python, status, twitter
blip.pl is a Polish microblogging service (some kind of Polish twitter). Today I’d like to present how to integrate python application (django application) with blip.pl API.
First of all… full documentation of blip.pl API is available here: http://blip.pl/api-0.02.html
It’s in Polish, however if you want to integrate your app with this service you propably know Polish (if not – notice, that it works as a standard REST + JSON compilation, so it shouldn’t be a problem to implement this functionality even for someone, who doesn’t Polish).
Ok, stop talking, start coding…
Open *.py file with your model and change “save()” method:
def save(self):
if not self.id:
if self.blip_message:
import httplib, base64
from django.utils import simplejson
http_url = 'http://api.blip.pl/updates'
API_HEADERS = {
'Content-Type' : 'application/json',
'X-Blip-api' : '0.02',
'User-Agent' : 'Karol Zielinski blip API',
'Authorization' : 'Basic %s' % (base64.b64encode('BLIP.PL_USERNAME:BLIP.PL_PASSWORD'))
}
update = {}
update['body'] = self.blip_message
post_params = simplejson.dumps(update)
connection = httplib.HTTPConnection('api.blip.pl')
connection.request('POST', http_url, headers=API_HEADERS, body=post_params)
response = connection.getresponse()
headers = response.getheaders()
status = response.status
resp_data = response.read()
and that’s all.
After you will add new item to this model – message from attribute blip_message will be added to your account on blip.pl.
Easy, isnt’t it?
Hello, I'm Karol Zielinski, internet evangelist, an entrepreneur, project manager and a web developer from Gdynia, Poland. I like creative design, good advertisement, social media and all kind of stuff around the web.
January 12, 2010, 7:51 am
[...] tech.karolzielinski.com Follow us on Twitter 1,521 śledzących RSS Feed 173 czytelników django + blip.pl: automatyczne nowe wiadomości 1 głosuj! Jak przy wykorzystaniu API serwowanego przez blip.pl stworzyć mechanizm, [...]
January 12, 2010, 8:02 am
Używanie base64 jest lekko niebezpieczne dlatego do api blipowego wprowadzono oauth: http://blip.pl/api-oauth.html
January 14, 2010, 7:30 am
[...] we created functionality for automatic adding of statuses to blip.pl. Today we would like to do the same thing, however for adding statuses to twitter.com. It will be [...]
January 14, 2010, 7:39 am
@after.design
I know that base64 is not so safe. However this way is much faster to implement.
May 19, 2010, 6:51 am
[...] we created functionality for automatic adding of statuses to blip.pl. Today we would like to do the same thing, however for adding statuses to twitter.com. It will be [...]