2010-10-17 5 views
1

Je voulais ajouter un flux Twitter à mon application. J'ai donc téléchargé python-twitter (avec python-oauth) et django-syncr. Installé tout et maintenant? Dans ma vue principale, je voulais effectuer une synchronisation Twitter. Ainsi, la recherche en paquets source et documentation j'ai pensé cet ordre:Utilisation de django-syncr avec twitter

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 ?! 

Cela ne fonctionne pas. J'obtiens l'erreur HTTP 401 - Aucune autorisation mais le nom et la passe sont corrects à coup sûr. Comment dois-je l'utiliser alors? Ai-je besoin d'une clé API de Twitter? Deuxièmement, que se passe-t-il dans ce code étape par étape? Quand est créé mon modèle django pour TweetUser, dans les méthodes privées? Et devrais-je créer un modèle TweetSyncr chaque fois que je veux synchroniser mon modèle avec un utilisateur tweeter? S'il vous plaît aider.

Lien aux auteurs d'instruction courte: 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: 
+0

Je viens de découvrir que Twitter a récemment changé l'authentification en OAuth. Donc j'utilise key/secret au lieu de user/pass? – DevAno1

+0

mope qui n'a pas fonctionné – DevAno1

Répondre

2

Je viens instructions ajouté la façon de traiter django-syncr et OAuth sur mon blog:

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

Fondamentalement, vous devez mettre à jour python-twitter à la version 0.9, puis faites quelques améliorations dans la méthode __init__ de syncr.api.tweet. Et vous, vous devez enregistrer une nouvelle application et obtenir des clés API.

+0

merci, maintenant ça marche! – DevAno1

Questions connexes