views:

69

answers:

1
+1  A: 

As @splix mentioned in the comments, doing this using just java.net is… suboptimal. I've never yet encountered a situation where HttpClient wasn't a better option. Event better is his suggestion of twitter4j; unless you're trying to create an alternative, it's almost always better to use an API wrapper like that vs. handling the raw HTTP interactions yourself.

UPDATE:

@Denzil it's odd that you're getting this same error even with twitter4j (I can't test the code until I get some free time to grab the lib, etc.) so I begin to suspect a problem on Twitter's end. If you have Python installed, try the following:

>>> import urllib
>>> urllib.urlopen("http://api.twitter.com/1/users/show/denzil_correa.json").read()

This worked for me.

UPDATE 2:

This definitely sounds like Twitter is intentionally refusing your requests. Possible reasons could include: your IP is on their blacklist for some reason, proxy voodoo, or things I haven't thought of. To elaborate on the proxy voodoo: I don't know what exactly it's doing to your requests, but it's possible it's adding a header or something that the Twitter API doesn't like. I'd recommend contacting Twitter support (if there is such a thing for API problems) or posting to the mailing list.

BTW, here's a thread from the mailing list that mentions ways to see if you're blacklisted.

Hank Gay
Hank/Splix, thanks for the response. My experience with Twitter4J is bad. The API returns erratic results for me viz. it sometime returns a result while sometimes doesn't.
Denzil
Hank, Tried the same in Python. Doesn't work ! :-O Check my edit for the error.
Denzil
Hank, Thanks for the update once again. But if I can get the details by posting it in a browser why would there be a problem when I do it via code?
Denzil
As @splix mentioned, there might be a difference between the proxied request from your browser and the proxied request from code. You might try checking the headers on the request from the browser and comparing them to the request from the code.
Hank Gay
Hank, Thanks for your response. What still befuddles me is that I use code itself to access the Facebook API without using any proxy authentication in my code. So, if it isn't required for Facebook API I am made to believe it isn't required while using Twitter too. Ultimately, both requests are simple HTTP requests and need to be handled in the same way. The inconsistency is what is still mucking up my head.
Denzil
@Denzil We're beyond anything I actually know anything about and into the realm of guesses. My *guess* is that Twitter doesn't like something that is happening to the proxied request, or possibly that the request is *not* being proxied outside the browser. Sorry I couldn't be more help.
Hank Gay
Hank, No issues. Thanks for all the help!
Denzil