Can't send tweet from my application

14 views
Skip to first unread message

Yannick

unread,
Sep 4, 2010, 6:39:00 PM9/4/10
to web2py-users
Hello Mate,
I used to send tweet through my application successfully without any
trouble but today I keep getting an "401: Unauthorized" when I send a
tweet from my application... Here is the code :
def postTweets():
try:
import urllib, urllib2, base64
import gluon.contrib.simplejson as sj
args= urllib.urlencode([('status',"My Message")])
headers={}
headers['Authorization'] = 'Basic
'+base64.b64encode("userName"+':' +"password")
request = urllib2.Request('http://twitter.com/statuses/
update.json', args, headers)
return sj.loads(urllib2.urlopen(request).read())
except Exception:
print 'Problem here'
raise

Here is the error I'm getting:
.....
....
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/urllib2.py", line 506, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 401: Unauthorized



Please any help... thanks

mdmcginn

unread,
Sep 4, 2010, 11:04:17 PM9/4/10
to web2py-users
I don't know if this is the solution, but Twitter is now requiring
OAuth instead of the previous Basic Auth. They've warned that many
apps would stop working. See http://dev.twitter.com/pages/basic_to_oauth
--
Michael McGinnis

Yannick

unread,
Sep 5, 2010, 11:40:21 AM9/5/10
to web2py-users
Thanks for the note and the link. Yes you right that's the reason why.
Twitter is no longer supporting Basic Authentication.
We need to use OAuth. I just read this post:
http://groups.google.com/group/web2py/browse_thread/thread/56e916dc8784e20a/ea6392970ae4cceb?lnk=gst&q=oAuth+twitter#ea6392970ae4cceb

And it looks like to send tweet, each user of my application should
get a CLIENT_ID, CLIENT_SECRET . I wonder where they will get it
from ? Should they have to register my application in thier twitter
Account to get it ?


Thanks,
Yannick P.

On Sep 4, 11:04 pm, mdmcginn <michael.d.mcgin...@gmail.com> wrote:
> I don't know if this is the solution, but Twitter is now requiring
> OAuth instead of the previous Basic Auth. They've warned that many
> apps would stop working. Seehttp://dev.twitter.com/pages/basic_to_oauth
Reply all
Reply to author
Forward
0 new messages