我想將twitter feed添加到我的應用程序中。所以我已經下載了python-twitter(使用python-oauth)和django-syncr。安裝了一切,現在什麼?在我的主視圖中,我想執行Twitter同步。因此,尋找到包源和documentation我已經想通這個命令:與twitter一起使用django-syncr
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 ?!
這是行不通的。我得到HTTP錯誤401 - 沒有授權,但名稱和通行證肯定是正確的。那麼我應該如何使用它?我需要Twitter的API密鑰嗎?其次是在這個代碼中一步一步發生了什麼?什麼時候創建TweetUser的django模型,在私有方法中創建?我是否應該每次創建TweetSyncr模型都要使用高音揚聲器用戶同步我的模型?請幫忙。
鏈接作者短指令: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._FetchUrl(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:
我剛剛發現twitter最近將身份驗證更改爲OAuth。所以我使用密鑰/祕密而不是用戶/密碼? – DevAno1 2010-10-18 01:13:54
沒有工作的地方 – DevAno1 2010-10-18 01:50:46