开发者

Using django-syncr with twitter

I wanted to add twitter feed to my application. So I've downloaded python-twitter (with python-oauth) and django-syncr. Installed everything and what now ? In my main view I wanted to perform Twitter synchronisation. So looking into packages source and documentation I've figured this order :

t = TwitterSyncr('name', 'pass') #: create TwitterSyncr for my user
t.syncUser('name') #: get info for user from twitter but why give name again ?
t.syncTwitterUserTweets('name') : #name again ?!

This doesn't work. I'm getting HTTP Error 401 - No authorization but name and pass are correct for sure. How should I use it then ? Do I need API key from Twitter ? Secondly what is going on in this code step by step ? When is my django model for TweetUser created, within the private methods ? And should I create TweetSyncr model each time I want to synchronize my model with tweeter user ? Please help.

Link to authors short instruction : http://jesselegg.com/archives/2008/02/19/django-syncr-synchronize-django-web/

Traceback:
File "/home/django/core/handlers/base.py" in get_response
  92.                 response = callback(request, *callback_args, **callback_kwargs)
File "/home/views.py" in landing
  27.     t.syncUser('username')
File "/home/syncr/tweet.py" in syncUser
  53.         user_obj = self._syncTwitterUser(self._getUser(user))
File "/home/syncr/tweet.py" in _getUser
  26.             tw_user = self.api.GetUser(user)
File "build/bdist.linux-x86_64/egg/twitter.py" in GetUser
  1633.     json = self._Fe开发者_如何学编程tchUrl(url)
File "build/bdist.linux-x86_64/egg/twitter.py" in _FetchUrl
  2032.         url_data = opener.open(url, encoded_post_data).read()
File "/bin/python-2.6.1/lib/python2.6/urllib2.py" in open
  389.             response = meth(req, response)
File "/bin/python-2.6.1/lib/python2.6/urllib2.py" in http_response
  502.                 'http', request, response, code, msg, hdrs)
File "/bin/python-2.6.1/lib/python2.6/urllib2.py" in error
  427.             return self._call_chain(*args)
File "/bin/python-2.6.1/lib/python2.6/urllib2.py" in _call_chain
  361.             result = func(*args)
File "/bin/python-2.6.1/lib/python2.6/urllib2.py" in http_error_default
  510.         raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)

Exception Type: HTTPError at /
Exception Value:


I have just added instruction how to deal with django-syncr and oauth on my blog :

http://fromzerotocodehero.blogspot.com/2010/10/synchronising-django-with-twitter-using.html

Basically you need to update python-twitter to 0.9 version and then do some improvements in __init__ method of syncr.api.tweet . And ye-s, you need to register a new app and get API keys.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜