Twitter's & Amazon EC2


#1

I amtry oauth_token from Amazon ec2, is not return anything fail.

If I send from godaddy twitter working find return the token abb7MdEEQ6Se3T4e7dGmfE5xoKRuhHjgOOSujLgPhQ


#2

Amazon ban IP address for twitters or what?


#3

is amazon.com url http://ec2-50-16-51-236.compute-1.amazonaws.com/twitter/


#4

no oauth_token, i host my code on http://ec2-50-16-51-236.compute-1.amazonaws.com/twitter/


#5

Hi @peermeup,

I’m trying to understand your issue but am at a loss as to what you’re experiencing.

Can you tell me the specific API end points you are hitting? What specific error responses are you getting? In response to which methods? Are you able to make basic curl requests to the Twitter API from the same machine? Have you verified that the server’s clock is in sync with Twitter’s?


#6

hi @episod

http://dhaliwalservices.com/twitter/index.php same code working here.

but when i move the code to Amazon EC2 http://ec2-50-16-51-236.compute-1.amazonaws.com/twitter/index.php. this not get the token from twitter.


#7

hi @episod

http://dhaliwalservices.com/twitter/index.php same code working here.

but when i move the code to Amazon EC2 http://ec2-50-16-51-236.compute-1.amazonaws.com/twitter/index.php. this not get the token from twitter.


#8

Hi there… I’m facing the same problem… on dev enviroment the authentication works fine, but when I put my web-app on amazon ec2 servers, twitter api just does not work for me…
here: http://stackoverflow.com/questions/1021212/twitter-search-api-blocked-from-amazon-ec2-in-ruby-only-not-curl-is-this-net
an user recommends to setting up my server’s user-agent to my domain. Is this correct, and if it is, where can I change that…

Thanks in advance for your comments.


#9

What’s the exact error you receive when executing the code on EC2 – the status code, message, and body of the response should tell you why the call could not be authorized. This is often due to clock mismatches on EC2.

The oauth/request_token and oauth/access_token end points aren’t “rate limited” in the way the proper API is. User agent has little meaning here – though it doesn’t hurt to use a unique one for proper identification.


#10

Hi Taylor… thanks for your help…
I’m using symfony and a plugin that allows me to get connected to twitter api (sfMelody) in my localhost, the log for the request looks like this:

Oct 18 14:32:29 symfony [info] {OAuth} call https://api.twitter.com/oauth/request_token with params oauth_callback=https%3A%2F%2Flocalhost%2Findex.php%2Faccess%2Ftwitter&oauth_consumer_key=fYUddJniczrFF3nXeLj4Ig&oauth_nonce=7dbf0ca059d64b9ed1278244554b6cf6&oauth_signature=bwOAka9KA%2FbOeuslCg0qd%2B2ZZIQ%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1318966349&oauth_version=1.0 |
Oct 18 14:32:30 symfony [info] {OAuth} twitter return Array
(
[oauth_token] => RBmkDhTNSnb4rceKnIYdZvOBH3zy5KmccJvmTRQRKA
[oauth_token_secret] => xxxxx
[oauth_callback_confirmed] => true
)

Oct 18 14:32:30 symfony [info] {Doctrine_Connection_Statement} execute : DELETE FROM token WHERE (status = ? AND name = ? AND user_id = ?) - (request, twitter, 1)
Oct 18 14:32:30 symfony [info] {OAuth} “twitter” call url “https://api.twitter.com/oauth/authorize” with params "array (
‘oauth_token’ => ‘xxxx’,
)"
Oct 18 14:32:30 symfony [info] {sfFrontWebController} Redirect to “https://api.twitter.com/oauth/authorize?oauth_token=RBmkDhTNSnb4rceKnIYdZvOBH3zy5KmccJvmTRQRKA

The same code and the same application running in ec2 server give me a log like this:

Oct 18 14:26:30 symfony [info] {OAuth} call https://api.twitter.com/oauth/request_token with params oauth_callback=http%3A%2F%2Fec2-174-129-169-151.compute-1.amazonaws .com%2Findex.php%2Faccess%2Ftwitter&oauth_consumer_key=fYUddJniczrFF3nXeLj4Ig&oauth_nonce=f1997fa8383d1ec4e0691c68d52e1250&oauth_signature=HeU3PXPo4rozpgXhJDvFqLueLsk% 3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1318947990&oauth_version=1.0 | Oct 18 14:26:30 symfony [err] {OAuth} access token failed - twitter returns Array ( [Failed to validate oauth signature and token] => )

Oct 18 14:26:30 symfony [info] {Doctrine_Connection_Statement} execute : DELETE FROM token WHERE (status = ? AND name = ? AND user_id = ?) - (request, twitter, 1)
Oct 18 14:26:30 symfony [info] {OAuth} “twitter” call url “https://api.twitter.com/oauth/authorize” with params "array (
‘oauth_token’ => NULL,
)"
Oct 18 14:26:30 symfony [info] {sfFrontWebController} Redirect to "https://api.twitter.com/oauth/authorize?"

It looks like the api twitter doesn’t give me a response because I’m using an ec2 server or something like that…

Again: Thanks in advance for your help…


#11

Thanks!!! in your response was the answer I had the same time but a diferent timezone…!!!

Again Thanks!


#12

glad you’ve figured it out. I noticed that you posted your consumer secret in the previous post – you should probably regenerate your API key and secret and access token and access token secret to prevent your keys from getting compromised.


#13

Hi Team,

I am getting the beloe exception when I tried to access Twitter Trends when the application is deployed in Amazon EC2. Could you please guide me what is the issue? When accessed in local machine with Tomcat server it is working fine. But when the same WAR is deployed in Amazon EC2, it is giving the below error. Any settings to be done? Please guide me. I am using twitter4j API.

Caused by: java.net.UnknownHostException: api.twitter.com
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:618)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.protocol.https.HttpsClient.(HttpsClient.java:275)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:371)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:932)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1300)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
at twitter4j.internal.http.HttpResponseImpl.(HttpResponseImpl.java:34)
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:141)
… 32 more
api.twitter.com
Relevant discussions can be found on the Internet at:
http://www.google.co.jp/search?q=53498236 or
http://www.google.co.jp/search?q=62f56a1e
TwitterException{exceptionCode=[53498236-62f56a1e c0ecfc1f-fbb7d568], statusCode=-1, message=null, code=-1, retryAfter=-1, rateLimitStatus=null, version=3.0.5}
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:177)
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:61)
at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:89)
at twitter4j.TwitterImpl.get(TwitterImpl.java:1911)
at twitter4j.TwitterImpl.getAvailableTrends(TwitterImpl.java:1736)
at com.twitter.tag.TwitterLocationTagHandler.doStartTag(TwitterLocationTagHandler.java:51)
at org.apache.jsp.twitter_005flocations_005finclude_jsp._jspx_meth_twitter_005flocations_005f0(twitter_005flocations_005finclude_jsp.java:372)
at org.apache.jsp.twitter_005flocations_005finclude_jsp._jspService(twitter_005flocations_005finclude_jsp.java:106)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)