403 on valid request to friendships/create/ if friendship already exists

38 views
Skip to first unread message

Ivan

unread,
Apr 17, 2009, 8:46:57 AM4/17/09
to Twitter Development Talk
Hi,

Twitter returns a HTTP 403 if you make a properly authorized follow
request to a user already followed.

That seems like the wrong kind of response. It should return 200, with
data saying the friendship already existed, no?

Ivan
http://tipjoy.com

Abraham Williams

unread,
Apr 17, 2009, 10:27:03 AM4/17/09
to twitter-deve...@googlegroups.com
This seems to indicate it too.

The 403 Forbidden HTTP status code indicates that the client was able to communicate with the server, but the server doesn't let the user access what was requested.
--
Abraham Williams | http://the.hackerconundrum.com
Hacker | http://abrah.am | http://twitter.com/abraham
Web608 | Community Evangelist | http://web608.org
This email is: [ ] blogable [x] ask first [ ] private.
Sent from Madison, Wisconsin, United States

Matt Sanford

unread,
Apr 17, 2009, 12:01:54 PM4/17/09
to twitter-deve...@googlegroups.com
Hi all,

    We're not seeing the 403s in our normal logs but we've seen a few in responses. We're looking into the issue and I'll send out more info when I have it.

— Matt

Ivan Kirigin

unread,
Apr 17, 2009, 12:24:16 PM4/17/09
to Twitter Development Talk
This could also just be a bug in the python code I'm using - maybe
even something in urllib2 going wrong.

Here is a bit of my code for reference, a function which makes an HTTP
POST with a username & password. For an existing friendship, this will
throw an exception printed out as:
<class 'urllib2.HTTPError'>
HTTP Error 403: Forbidden
<traceback object at 0x1ea38a0>


import sys
import urllib2
import urlparse
import json
def twitter_post_pw(url, data, twitter_username, twitter_password):
encoded_data = twitter_encode(data)
realm = "Twitter API"
(scheme, netloc, path, params, query, fragment) = urlparse.urlparse
(url)
handler = urllib2.HTTPBasicAuthHandler()
handler.add_password(realm, netloc, twitter_username,
twitter_password)
opener = urllib2.build_opener(handler)
try:
o = opener.open(url, encoded_data)
return json.read( o.read() )
except:
for e in sys.exc_info():
print e
return False

def twitter_encode( data ):
return urllib.urlencode(dict([(k, unicode(v).encode('utf-8')) for
k, v in data.items()]))

On Apr 17, 12:01 pm, Matt Sanford <m...@twitter.com> wrote:
> Hi all,
>
>      We're not seeing the 403s in our normal logs but we've seen a few  
> in responses. We're looking into the issue and I'll send out more info  
> when I have it.
>
> — Matt
>
> On Apr 17, 2009, at 07:27 AM, Abraham Williams wrote:
>
> > This seems to indicate it too.
>
> > The 403 Forbidden HTTP status code indicates that the client was  
> > able to communicate with the server, but the server doesn't let the  
> > user access what was requested.
>
> >http://en.wikipedia.org/wiki/HTTP_403
>

Matt Sanford

unread,
Apr 17, 2009, 12:31:01 PM4/17/09
to Twitter Development Talk
Hi all,

    The issue with random HTTP 403s on search (both API and web) should now be fixed. Similar to the employee password prompts a few days ago we had a host unexpectedly join the search cluster. We want more capacity so bad we're actually convincing inanimate objects to join our cause. ¡Viva La Revolución! Unfortunately the host wasn't ready for the job it volunteered for … we've put the poor thing out of its misery.

Thanks;
  — Matt

Matt Sanford

unread,
Apr 17, 2009, 12:36:10 PM4/17/09
to Twitter Development Talk
Woops, wrong 403 thread. My last two mails were about the search 403s.
Sorry about that.

— Matt

On Apr 17, 9:31 am, Matt Sanford <m...@twitter.com> wrote:
> Hi all,
>
>      The issue with random HTTP 403s on search (both API and web)  
> should now be fixed. Similar to the employee password prompts a few  
> days ago we had a host unexpectedly join the search cluster. We want  
> more capacity so bad we're actually convincing inanimate objects to  
> join our cause. ¡Viva La Revolución! Unfortunately the host wasn't  
> ready for the job it volunteered for … we've put the poor thing out of  
> its misery.
>
> Thanks;
>    — Matt
>
> On Apr 17, 2009, at 09:01 AM, Matt Sanford wrote:
>
> > Hi all,
>
> >     We're not seeing the 403s in our normal logs but we've seen a  
> > few in responses. We're looking into the issue and I'll send out  
> > more info when I have it.
>
> > — Matt
>
> > On Apr 17, 2009, at 07:27 AM, Abraham Williams wrote:
>
> >> This seems to indicate it too.
>
> >> The 403 Forbidden HTTP status code indicates that the client was  
> >> able to communicate with the server, but the server doesn't let the  
> >> user access what was requested.
>
> >>http://en.wikipedia.org/wiki/HTTP_403
>
Reply all
Reply to author
Forward
0 new messages