S
saqib.ali.75
I posted this on StackOverflow.com but haven't got a good response yet: http://stackoverflow.com/questions/14808245/python-why-cant-i-send-a-tweet
I have tried two different packages python-twitter and tweepy but have not been successful using either package. Those solutions are discussed here:
Twitter API: simple status update (Python) How to tweet from Django?
Firstly, I should make clear that I have just created a Twitter account a couple of hours ago from which to send tweets. Using dev.twitter.com, I haveset the access level to "Read, write, and direct messages" and I have created consumer and access token keys.
Using these keys, I connect to twitter using the python-twitter package. I know it is at least partially working because I can access The Biebs tweets:
http://t.co/q58qksxp its not finished but heres a little part a song I'm working on
sorry http://t.co/Vtu4Lc2Q
video is at 13 percent done uploading
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/python_twitter-0.8.5-py2.7.egg/twitter.py", line 2838, in PostUpdate
data = self._ParseAndCheckTwitter(json)
File "/usr/local/lib/python2.7/dist-packages/python_twitter-0.8.5-py2.7.egg/twitter.py", line 3869, in _ParseAndCheckTwitter
self._CheckForTwitterError(data)
File "/usr/local/lib/python2.7/dist-packages/python_twitter-0.8.5-py2.7.egg/twitter.py", line 3892, in _CheckForTwitterError
raise TwitterError(data['error'])
twitter.TwitterError: Could not authenticate with OAuth.
Can someone explain why? Since that didn't work, I decided to install and try tweepy.
But when I try to use it, it gives me the error "Invalid or expired token"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 11, in tweet
File "/usr/local/lib/python2.7/dist-packages/tweepy-2.0-py2.7.egg/tweepy/binder.py", line 185, in _call
return method.execute()
File "/usr/local/lib/python2.7/dist-packages/tweepy-2.0-py2.7.egg/tweepy/binder.py", line 168, in execute
raise TweepError(error_msg, resp)
tweepy.error.TweepError: [{u'message': u'Invalid or expired token', u'code': 89}]
What is the solution here? Are my keys from Twitter wrong?
I have tried two different packages python-twitter and tweepy but have not been successful using either package. Those solutions are discussed here:
Twitter API: simple status update (Python) How to tweet from Django?
Firstly, I should make clear that I have just created a Twitter account a couple of hours ago from which to send tweets. Using dev.twitter.com, I haveset the access level to "Read, write, and direct messages" and I have created consumer and access token keys.
Using these keys, I connect to twitter using the python-twitter package. I know it is at least partially working because I can access The Biebs tweets:
http://t.co/q58qksxp its not finished but heres a little part a song I'm working on
sorry http://t.co/Vtu4Lc2Q
video is at 13 percent done uploading
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/python_twitter-0.8.5-py2.7.egg/twitter.py", line 2838, in PostUpdate
data = self._ParseAndCheckTwitter(json)
File "/usr/local/lib/python2.7/dist-packages/python_twitter-0.8.5-py2.7.egg/twitter.py", line 3869, in _ParseAndCheckTwitter
self._CheckForTwitterError(data)
File "/usr/local/lib/python2.7/dist-packages/python_twitter-0.8.5-py2.7.egg/twitter.py", line 3892, in _CheckForTwitterError
raise TwitterError(data['error'])
twitter.TwitterError: Could not authenticate with OAuth.
Can someone explain why? Since that didn't work, I decided to install and try tweepy.
But when I try to use it, it gives me the error "Invalid or expired token"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 11, in tweet
File "/usr/local/lib/python2.7/dist-packages/tweepy-2.0-py2.7.egg/tweepy/binder.py", line 185, in _call
return method.execute()
File "/usr/local/lib/python2.7/dist-packages/tweepy-2.0-py2.7.egg/tweepy/binder.py", line 168, in execute
raise TweepError(error_msg, resp)
tweepy.error.TweepError: [{u'message': u'Invalid or expired token', u'code': 89}]
What is the solution here? Are my keys from Twitter wrong?