I am using Twitter4J 2.2.5 (latest, tried other versions). And can no longer get direct messages to work at all. The same code used to work a while ago. I assume Twitter changed something.
I'm using
Twitter.getDirectMessages()
and it gives the error below. No idea why, I can see the direct messages for the account if I login, but always get this error. The limit error makes no sense, as the account is no where near the limit.
Other API work, like followers/fried/status/etc.
403:The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits (http://support.twitter.com/forums/10711/entries/15364).
Relevant discussions can be on the Internet at:
http://www.google.co.jp/search?q=00919618 or
http://www.google.co.jp/search?q=332bf6ca
TwitterException{exceptionCode=[00919618-332bf6ca], statusCode=403, retryAfter=0, rateLimitStatus=RateLimitStatusJSONImpl{remainingHits=107, hourlyLimit=350, resetTimeInSeconds=1328297, secondsUntilReset=1116, resetTime=Fri Feb 03 14:39:45 EST 2012}, version=2.2.2}
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:189)
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:65)
at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:93)
at twitter4j.TwitterImpl.get(TwitterImpl.java:1721)
at twitter4j.TwitterImpl.getDirectMessages(TwitterImpl.java:874)
at org.pandora.sense.twitter.TwitterDirectMessaging.checkDirectMessages(TwitterDirectMessaging.java:44)
at org.pandora.sense.twitter.TwitterDirectMessaging.checkProfile(TwitterDirectMessaging.java:35)
at org.pandora.sense.twitter.Twitter$1.run(Twitter.java:100)
at java.lang.Thread.run(Thread.java:662)
Twitter has some time ago changed the rules for direct messages. An app must be especially authorized by the user to access the direct messages.
Did you make sure this is true for you? You may go to the twitter web site and check for the app.
To get the direct message you should try the below code.It works for me.
getDirectMessages(); gives list of direct messages. We need to put for loop to get text of each message.
List<DirectMessage> messages = twitter.getDirectMessages();
for (DirectMessage message : messages)
{
System.out.println(message.getText());
}
Let me know if you get any error.
Related
The error message suggests that my "request was denied due to update limits". But this account hasn't tweeted anythin in the last 24 hours and it also says retryAfter=-1. I tried it with the current stable and the snapshot build of twitter4j but it didn't help. Does someone know what is wrong?
403:The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits (https://support.twitter.com/articles/15364-about-twitter-limits-update-api-dm-and-following).
message - Application cannot perform write actions. Contact Twitter Platform Operations through https://support.twitter.com/forms/platform
code - 261
Relevant discussions can be found on the Internet at:
http://www.google.co.jp/search?q=2fc5b7cb or
http://www.google.co.jp/search?q=0f38fea7
TwitterException{exceptionCode=[2fc5b7cb-0f38fea7], statusCode=403, message=Application cannot perform write actions. Contact Twitter Platform Operations through https://support.twitter.com/forms/platform, code=261, retryAfter=-1, rateLimitStatus=null, version=4.0.5-SNAPSHOT(build: bbbd24f6c492677f65d3956ed6b74a2ae75d5bc3)}
at twitter4j.HttpClientImpl.handleRequest(HttpClientImpl.java:164)
at twitter4j.HttpClientBase.request(HttpClientBase.java:57)
at twitter4j.HttpClientBase.post(HttpClientBase.java:86)
at twitter4j.TwitterImpl.post(TwitterImpl.java:1812)
at twitter4j.TwitterImpl.updateStatus(TwitterImpl.java:218)
Code 261 means the API-token was suspended. It takes only 10 minutes to appeal the suspension and get everything up and running again.
If the suspension isn't lifted (I appealed several times but it didn't), you could create a new standalone app (in the overview) and replace the consumer and access tokens with the new ones. It worked for me.
In play framework, every time you get an Internal Server Error (500) in production mode, the browser shows a web page with
Oops, an error occured, This exception has been logged with id XXXX
I would like to customize the error message (or at least translate it to spanish), keeping the error id that makes it easier to look for in the application log.
I've tried to configure an error page in the Global settings in JAVA like this:
public Promise<Result> onError(RequestHeader request, Throwable t) {
return Promise.<Result>pure(internalServerError(
views.html.error.render(t)
));
}
Where I've a view named error.scala.html.
It is not working right now, it does not show any errors, just ignores it. Also with this alternative, I don't know how to display the error id.
I appreciate any suggestions, thanks a lot.
Is your Global class in the root package? That's a quite common mistake and also the reason why it is ignored.
Summary
This happened since May 20th's night (Pacific Time). Initially, I thought it was Google Cloud Storage failure. It seems now that they supported my way of storing data before. But somehow, after May 20th, that API does not work the same way as before.
How did I call
GcsFileOptions fileOptions = new GcsFileOptions.Builder().mimeType("image/png").acl("public-read").build();
GcsFilename filename = new GcsFilename(fileBucket, objectName); // fileBucket="test", objectName="/code/my/yeuei"
GcsService service = GcsServiceFactory.createGcsService();
GcsOutputChannel oc = service.createOrReplace(filename,fileOptions); //error happens here.
Error
Google Cloud Storage API gives error when the object is not existing.
GcsServiceImpl.createOrReplace method
I am creating a new object.
E 10:03:00.643 com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException: The RuntimeException could not be mapped to a response, re-throwing to the HTTP container
com.google.appengine.tools.cloudstorage.NonRetriableException: java.lang.NullPointerException
at com.google.appengine.tools.cloudstorage.RetryHelper.doRetry(RetryHelper.java:120)
at com.google.appengine.tools.cloudstorage.RetryHelper.runWithRetries(RetryHelper.java:166)
at com.google.appengine.tools.cloudstorage.RetryHelper.runWithRetries(RetryHelper.java:156)
at com.google.appengine.tools.cloudstorage.GcsServiceImpl.createOrReplace(GcsServiceImpl.java:68)
This line seems causing the error -
Caused by: java.lang.NullPointerException
at com.google.appengine.tools.cloudstorage.oauth.URLFetchUtils$HTTPRequestInfo.<init>(URLFetchUtils.java:80)
at com.google.appengine.tools.cloudstorage.oauth.OauthRawGcsService.beginObjectCreation(OauthRawGcsService.java:184)
at com.google.appengine.tools.cloudstorage.GcsServiceImpl$1.call(GcsServiceImpl.java:71)
at com.google.appengine.tools.cloudstorage.GcsServiceImpl$1.call(GcsServiceImpl.java:68)
at com.google.appengine.tools.cloudstorage.RetryHelper.doRetry(RetryHelper.java:108)
Nothing on the status page. You might wish to check it in the future.
Ok. This is resolved. I am still not sure how it is introduced in the first place.
Here is what happens -
There is a class URLFetchUtils in App Engine GCS Client library, when it initiates, it did not check if payload is null, that creates the NullPointer exception. Today, GCS Java Client Library has an update fixed this issue, so if you use the latest version (app engine GCS 0.3.12), this error will go away. Interestingly, I have no idea how it worked before :) ... But anyway, I am glad that my app is working again - after about 24 hours down.
Does gmail support RFC1892(Delivery Status Notification) ?
If so, how can I use JavaMail to parse the DSN. (Sample code is highly appreciated)
If not, When a email can't be delivered through gmail, a failure message is returned. How can I detect these "bounced" messages?
1 - I don't know.
2 - Add dsn.jar from JavaMail to your classpath. Then use something like this:
if (msg.isMimeType("multipart/report")) {
MultipartReport r = (MultipartReport)msg.getContent();
// see com.sun.mail.dsn package javadocs for MutlipartReport
}
3 - http://www.oracle.com/technetwork/java/javamail/faq/index.html#bounce
Related to this question.
The X-Failed-Recipients header seems to be the quickest way to identify gmail DSN. After that, it seems you must parse the text/plain content.
The subject seems to be Delivery Status Notification (*status*) where statuses that I've seen are: Failure, Delay.
I'm trying to publish a photo to a page using the following:
FacebookClient client = new DefaultFacebookClient(destinationAccessToken);
BinaryAttachment attachment = BinaryAttachment.with(imageName, imageInputStream);
Photo photoResponse = client.publish("/me/photos", Photo.class, attachment);
I'm getting the following response:
{
"error": {
"message":"An unexpected error has occurred. Please retry your request later.",
"type":"OAuthException",
"code":2
}
}
When I use the same code to publish to a user wall it works fine.
I've also tried posting to "/{page id}/photos" with the same result.
The destination access token has the manage_pages, photo_upload, publish_actions, and publish_stream permissions amongst others.
What am I doing wrong here?
UPDATE:
If I publish to a predetermined album using "/{album id}/photos" then it works. Quoting this Facebook developer blog post:
https://graph.facebook.com/USER_ID/photos - The photo will be
published to an album created for your app. We automatically create an
album for your app if it does not already exist. All photos uploaded
this way will then be added to this same album.
So is this behavior broken for pages? Or am I misunderstanding something here?
UPDATE 2:
I found a bug report for this issue, so I'm posting that as an answer.
UPDATE 3:
The bug seems to have been resolved.
I found the Facebook bug report corresponding to this behavior:
http://developers.facebook.com/bugs/355536551171535
So it would seem I'm not doing anything wrong. I guess the temporary workaround would be to check for a predetermined album and create it if necessary, then publish to it. (Note that the user_photos permission is not needed for this workaround, since albums/photos on pages are always public).