Twitter4j search returns results with many fields.
ex:
StatusJSONImpl{createdAt=Fri Jan 09 19:56:31 IST 2015, id=553558441482924033, text='Avast Free Antivirus 2015 [Download]: Avast Free Antivirus 2015 [Download] by AVAST Software s.r.o. Platform:… http://t.co/0zLPutC1PU', source='dlvr.it', isTruncated=false, inReplyToStatusId=-1, inReplyToUserId=-1, isFavorited=false, isRetweeted=false, favoriteCount=0, inReplyToScreenName='null', geoLocation=null, place=null, retweetCount=0, isPossiblySensitive=false, isoLanguageCode='en', lang='en', contributorsIDs=[], retweetedStatus=null, userMentionEntities=[], urlEntities=[URLEntityJSONImpl{url='http://t.co/0zLPutC1PU', expandedURL='http://amzn.to/1q69X9Z', displayURL='amzn.to/1q69X9Z'}], hashtagEntities=[], mediaEntities=[], symbolEntities=[], currentUserRetweetId=-1, user=UserJSONImpl{id=2792966010, name='Jessica', screenName='JessicaN372', location='US', description='Jessica', isContributorsEnabled=false, profileImageUrl='http://pbs.twimg.com/profile_images/508946722307846144/E5Bi70E8_normal.jpeg', profileImageUrlHttps='https://pbs.twimg.com/profile_images/508946722307846144/E5Bi70E8_normal.jpeg', url='null', isProtected=false, followersCount=128, status=null, profileBackgroundColor='C0DEED', profileTextColor='333333', profileLinkColor='0084B4', profileSidebarFillColor='DDEEF6', profileSidebarBorderColor='C0DEED', profileUseBackgroundImage=true, showAllInlineMedia=false, friendsCount=0, createdAt=Sat Sep 06 08:13:33 IST 2014, favouritesCount=0, utcOffset=-1, timeZone='null', profileBackgroundImageUrl='http://abs.twimg.com/images/themes/theme1/bg.png', profileBackgroundImageUrlHttps='https://abs.twimg.com/images/themes/theme1/bg.png', profileBackgroundTiled=false, lang='en', statusesCount=148653, isGeoEnabled=false, isVerified=false, translator=false, listedCount=2, isFollowRequestSent=false}}
Where I only require text and links.
How to request only certain fields
It's not possible to request certain fields as the Twitter Search API doesn't provide this functionality.
Instead you will need to extract what you are interested in from the Status yourself.
In your case you can use status.getText() and status.getUrlEntities() to get what you want.
Related
When the VaadinSession timeout happens, the page automatically reloads starting a new VaadinSession.
Vaadin 23.0.5
Below, I have included the Chrome console log as the session ends and the reload happens.
There is nothing indicating why this is going on in the java logs.
This appears (to me) to be initiated in the browser, possibly by the service worker?
Suggestions for further diagnostics, or just an outright solution (I can dream) would be greatly appreciated.
Here is the Chrome console as the Session terminates...
Received push (websocket) message: for(;;);[{"syncId":4,"clientId":2,"meta":{"async":true,"sessionExpired":true},"timings":[5,0]}]
FlowClient.js?2d7e:1004 Handling message from server
FlowClient.js?2d7e:944 Handling dependencies
FlowClient.js?2d7e:193 handleUIDLMessage: 0 ms
vaadinPush.js?v=23.0.4:3323 Mon Jun 06 2022 13:41:09 GMT+1000 (Australian Eastern Standard Time) Atmosphere: beforeunload event
FlowClient.js?2d7e:193 Setting heartbeat interval to -1sec.
FlowClient.js?2d7e:835 Disabling heartbeat
FlowClient.js?2d7e:936 Closing push connection
vaadinPush.js?v=23.0.4:3323 Mon Jun 06 2022 13:41:09 GMT+1000 (Australian Eastern Standard Time) Atmosphere: Closing (AtmosphereRequest._close() called)
vaadinPush.js?v=23.0.4:3323 Mon Jun 06 2022 13:41:09 GMT+1000 (Australian Eastern Standard Time) Atmosphere: Firing onClose (unsubscribe case)
FlowClient.js?2d7e:1006 Push connection closed
vaadinPush.js?v=23.0.4:3323 Mon Jun 06 2022 13:41:09 GMT+1000 (Australian Eastern Standard Time) Atmosphere: Request already closed, not firing onClose (unsubscribe case)
vaadinPush.js?v=23.0.4:3323 Mon Jun 06 2022 13:41:09 GMT+1000 (Australian Eastern Standard Time) Atmosphere: invoking .close() on WebSocket object
FlowClient.js?2d7e:193 Processing time was 5ms
vaadinPush.js?v=23.0.4:3323 Mon Jun 06 2022 13:41:09 GMT+1000 (Australian Eastern Standard Time) Atmosphere: Request already closed, not firing onClose (unsubscribe case)
logger.js?aa4d:46 workbox No route found for: /?v-r=push&v-uiId=0&v-pushId=09139213-af19-48d7-8a55-278da41b839f&X-Atmosphere-Transport=close&X-Atmosphere-tracking-id=3c2a0c76-86d7-4952-a1c4-80786dd19bd0
vaadinPush.js?v=23.0.4:3323 Mon Jun 06 2022 13:41:09 GMT+1000 (Australian Eastern Standard Time) Atmosphere: websocket.onclose
vaadinPush.js?v=23.0.4:3323 Websocket closed, reason: Normal closure; the connection successfully completed whatever purpose for which it was created. - wasClean: true
log # vaadinPush.js?v=23.0.4:3323
warn # vaadinPush.js?v=23.0.4:3329
_websocket.onclose # vaadinPush.js?v=23.0.4:1537
vaadinPush.js?v=23.0.4:3323 Mon Jun 06 2022 13:41:09 GMT+1000 (Australian Eastern Standard Time) Atmosphere: Request already closed, not firing onClose (closed case)
vaadinPush.js?v=23.0.4:3323 Mon Jun 06 2022 13:41:09 GMT+1000 (Australian Eastern Standard Time) Atmosphere: Request already closed, not firing onClose (closed case)
vaadinPush.js?v=23.0.4:3323 Websocket closed normally
Which is immediately followed with the page reloading...
logger.js?aa4d:46 workbox The navigation route / is being used.
logger.js?aa4d:46 workbox Router is responding to: /
logger.js?aa4d:46 workbox Network request for '/' returned a response with status '200'.
logger.js?aa4d:46 workbox Using NetworkOnly to respond to '/'
Mon Jun 06 2022 13:41:11 GMT+1000 (Australian Eastern Standard Time) Atmosphere: unload event
logger.js?aa4d:46 workbox No route found for:
https://api.breadbutter.io/apps/xxxxxxxxxxxxxxxx/prerelease/page_engagement
logger.js?aa4d:46 workbox Router is responding to: /VAADIN/build/vaadin-bundle-52a045587b10cc017547.cache.js
logger.js?aa4d:46 workbox Found a cached response in 'workbox-precache-v2-https://mylocalhost/'.
logger.js?aa4d:46 workbox Precaching did not find a match for /?v-r=init&location=
logger.js?aa4d:46 workbox No route found for: /?v-r=init&location=
logger.js?aa4d:46
Yes, this is intended behavior.
You need to setup servlet initialized listener and there define customized system messages, there sessionExpiredURL needs to be not null (null is the default value, and if it is null, page will reload upon session expired)
getService()
.setSystemMessagesProvider(new SystemMessagesProvider() {
#Override
public SystemMessages getSystemMessages(
SystemMessagesInfo systemMessagesInfo) {
CustomizedSystemMessages messages = new CustomizedSystemMessages();
messages.setSessionExpiredNotificationEnabled(
false); // or true
messages.setSessionExpiredURL( USE NON-NULL VALUE HERE );
return messages;
}
});
I am currently developing a Web Service RESTFUL.
To test the Web Service, I'm using SOAP UI.
While performing testing, I got the error Illegal character in path.
May I know what is the cause of the error? How to fix the issue?
Below is the detail of the problem.
Error Log:
Wed Nov 28 17:05:26 SGT 2018:ERROR:java.net.URISyntaxException: Illegal character in path at index 62: http://127.0.0.1:8080/AdaptiveAuthWSApps/rest/AdaptiveService/{uuid}/{browserinfo}/{ipint}/{lat}/{longitude}/{sessionid}/{spid}/{tr}/{jsnum}/{fingerprint}/{methodset}
java.net.URISyntaxException: Illegal character in path at index 62: http://127.0.0.1:8080/AdaptiveAuthWSApps/rest/AdaptiveService/{uuid}/{browserinfo}/{ipint}/{lat}/{longitude}/{sessionid}/{spid}/{tr}/{jsnum}/{fingerprint}/{methodset}
SOAP UI Log:
Wed Nov 28 17:05:26 SGT 2018:ERROR:An error occurred [Illegal character in path at index 62: http://127.0.0.1:8080/AdaptiveAuthWSApps/rest/AdaptiveService/{uuid}/{browserinfo}/{ipint}/{lat}/{longitude}/{sessionid}/{spid}/{tr}/{jsnum}/{fingerprint}/{methodset}], see error log for details
Wed Nov 28 17:05:26 SGT 2018:DEBUG:Attempt 1 to execute request
Wed Nov 28 17:05:26 SGT 2018:DEBUG:Sending request: POST /?uuid=iz23456&browserinfo=Mozilla%2F8.0%20%28Windows%20NT%206.1%29%20AppleWebKit%2F537.36%20%28KHTML%2C%20like%20Gecko%29%20Chrome%2F49.0.2623.112%20Safari%2F537.36&ipint=16885247&lat=1&longitude=0&sessionid=12w3e4&spid=https%3A%2F%2Fuap%2Fowa&tr=10&jsnum=2&fingerprint=yh8u87&methodset=1%2C1 HTTP/1.1
Wed Nov 28 17:05:26 SGT 2018:DEBUG:Receiving response: HTTP/1.1 200
Wed Nov 28 17:05:26 SGT 2018:DEBUG:Connection can be kept alive indefinitely
Below is the WADL that I used when creating the Test Suite in SOAP UI.
http://127.0.0.1:8080/AdaptiveAuthWSApps/rest/application.wadl
SOAP UI parameter initialize:
I believe the problem is the value of your uuid parameter.
A uuid should consist solely of hexadecimal characters. That is 0-9 and a-f (and also the "-" of course)
You've written iz123456, and neither "i" or "z" are valid.
If the uuid also should be an actual uuid, then it should look something like this: 13a1a079-4a39-4625-91a4-ddbf09c2c324
Try copy/pasting this uuid into your uuid parameter, and run it again.
It looks like you're getting your parameter styles mixed up. If you define a style of QUERY, the key/value pairs are added after the question mark in the URL, not added to the resource path. Using {uuid}/{browserinfo}/... is a TEMPLATE style.
So, remove {uuid}/{browserinfo}/... from your resource path and just leave the key/value pairs after the question mark.
My team and I coded a mail component to be used by other teams in our application. This component is designed to allow them to download emails using custom search conditions. The one that is being used at the moment is a mail search between a range of dates from Gmail accounts using IMAP protocol. It was working properly until April 4th 2016 6:00AM GMT+1, only downloading email within the range. However, since 8:00AM GMT+1, the response from the server suddenly changed and it started returning the whole INBOX folder!
Repeating the initial tests, we discovered that we were receiving the whole INBOX folder instead of those within the range. After some research down to the IMAP request, it seemed that Gmail changed the amount of emails returned under certain conditions:
When the "start date" SearchTerm had a ComparisonTerm.GT term, or
When the "end date" SearchTerm had a ComparisonTerm.LE term
In both cases, Gmail's IMAP server returns all the emails in the folder. On the contrary, as an example, Yahoo's IMAP server just returns those emails which match the given condition.
We opened a ticket to them, asking if there was any change in their response, but they answered that they did not change anything. Of course, there is no way to prove it (we still don't have the time machine).
As we had a great impact with this unexpected behaviour, we decided to investigate further, and we created a simple mail client to download mail using different condition combinations from different IMAP servers.
Starting from this link's program, we added the functionality to check with other, but changing the library to meet our javax.mail version 1.5.5. Therefore, we avoid different implementation behaviours.
The code is attached below:
package gmail;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.search.AndTerm;
import javax.mail.search.ComparisonTerm;
import javax.mail.search.ReceivedDateTerm;
import javax.mail.search.SearchTerm;
public class JavaMailTest {
public static void main(String[] args) {
JavaMailTest testClient=new JavaMailTest();
//Yahoo
//SEARCH SINCE 3-Apr-2016 BEFORE 7-Apr-2016 ALL
testClient.performTest(testClient.getYahooImapProps(),ComparisonTerm.GE,ComparisonTerm.LT);
//Gmail
//SEARCH SINCE 3-Apr-2016 BEFORE 7-Apr-2016 ALL
testClient.performTest(testClient.getGmailImapProps(),ComparisonTerm.GE,ComparisonTerm.LT);
//Yahoo
//SEARCH SINCE 3-Apr-2016 OR BEFORE 7-Apr-2016 ON 7-Apr-2016 ALL
testClient.performTest(testClient.getYahooImapProps(),ComparisonTerm.GE,ComparisonTerm.LE);
//Gmail
//SEARCH SINCE 3-Apr-2016 OR BEFORE 7-Apr-2016 ON 7-Apr-2016 ALL
testClient.performTest(testClient.getGmailImapProps(),ComparisonTerm.GE,ComparisonTerm.LE);
//Yahoo
//SEARCH NOT ON 3-Apr-2016 SINCE 3-Apr-2016 BEFORE 7-Apr-2016 ALL
testClient.performTest(testClient.getYahooImapProps(),ComparisonTerm.GT,ComparisonTerm.LT);
//Gmail
//SEARCH NOT ON 3-Apr-2016 SINCE 3-Apr-2016 BEFORE 7-Apr-2016 ALL
testClient.performTest(testClient.getGmailImapProps(),ComparisonTerm.GT,ComparisonTerm.LT);
//Yahoo
//SEARCH NOT ON 3-Apr-2016 SINCE 3-Apr-2016 OR BEFORE 7-Apr-2016 ON 7-Apr-2016 ALL
testClient.performTest(testClient.getYahooImapProps(),ComparisonTerm.GT,ComparisonTerm.LE);
//Gmail
//SEARCH NOT ON 3-Apr-2016 SINCE 3-Apr-2016 OR BEFORE 7-Apr-2016 ON 7-Apr-2016 ALL
testClient.performTest(testClient.getGmailImapProps(),ComparisonTerm.GT,ComparisonTerm.LE);
}
public int performTest(Properties props, int startTermCondition, int endTermCondition)
{
try {
Session session = Session.getDefaultInstance(props, null);
Message[] totalMessages = null;
Store store = session.getStore(props.getProperty("protocol"));
store.connect(props.getProperty("mail.imap.host"), props.getProperty("account"), props.getProperty("pass"));
Folder inbox = store.getFolder("inbox");
inbox.open(Folder.READ_ONLY);
SimpleDateFormat ft = new SimpleDateFormat ("yyyy-MM-dd");
Date startDate = ft.parse("2016-04-03");
Date endDate = ft.parse("2016-04-07");
System.out.println("Testing email account: <"+props.getProperty("account")+"> with startDate: <" + startDate + "> (ComparisonTerm."+
getConditionText(startTermCondition)+") and endDate: <" + endDate+"> (ComparisonTerm."+getConditionText(endTermCondition)+")");
Message[] messages = inbox.getMessages();
if (messages != null && messages.length > 0) {
SearchTerm startDateTearm =
new ReceivedDateTerm(startTermCondition, startDate);
SearchTerm endDateTerm =
new ReceivedDateTerm(endTermCondition, endDate);
SearchTerm andTerm = new AndTerm(startDateTearm, endDateTerm);
totalMessages = inbox.search(andTerm);
if(totalMessages.length > 0){
System.out.println("Found "+totalMessages.length+" matching messages (Total messages in folder: "+messages.length+")");
}
/*for (int i = 0; i < totalMessages.length; i++) {
System.out.println(totalMessages[i].getReceivedDate() + " --> Mail Subject:- " + totalMessages[i].getSubject());
}*/
//First message
int currentMessage=0;
System.out.println("First Message: "+totalMessages[currentMessage].getReceivedDate() + " --> Mail Subject: " + totalMessages[currentMessage].getSubject().substring(0, 5));
//Last message
currentMessage=totalMessages.length-1;
System.out.println("Last Message: "+totalMessages[currentMessage].getReceivedDate() + " --> Mail Subject: " + totalMessages[currentMessage].getSubject().substring(0, 5));
}
inbox.close(true);
store.close();
return totalMessages.length;
} catch (Exception e) {
e.printStackTrace();
return -1;
}
}
public static String getConditionText(int condition)
{
String returnValue="";
switch (condition) {
case ComparisonTerm.EQ:
returnValue="EQ";
break;
case ComparisonTerm.GE:
returnValue="GE";
break;
case ComparisonTerm.GT:
returnValue="GT";
break;
case ComparisonTerm.LE:
returnValue="LE";
break;
case ComparisonTerm.LT:
returnValue="LT";
break;
case ComparisonTerm.NE:
returnValue="NE";
break;
default:
returnValue="Error";
break;
}
return returnValue;
}
public Properties getYahooImapProps()
{
Properties props = new Properties();
//Yahoo
String imapServer="imap.mail.yahoo.com";
String imapPort="993";
String account="********#yahoo.es";
String pass="*********";
props.setProperty("mail.imap.host", imapServer);
props.setProperty("mail.imap.port", imapPort);
props.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.setProperty("mail.imap.auth", "true");
props.setProperty("account", account);
props.setProperty("pass", pass);
props.setProperty("protocol", "imaps");
return props;
}
public Properties getGmailImapProps()
{
Properties props = new Properties();
//Gmail
String imapServer="imap.gmail.com";
String imapPort="143";
String account="******#gmail.com";
String pass="********";
props.setProperty("mail.imap.host", imapServer);
props.setProperty("mail.imap.port", imapPort);
/*props.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.setProperty("mail.imap.auth", "true");*/
props.setProperty("account", account);
props.setProperty("pass", pass);
props.setProperty("protocol", "imap");
return props;
}
}
To make the program output clearer, I added the request right before the first method output:
//SEARCH SINCE 3-Apr-2016 BEFORE 7-Apr-2016 ALL
Testing email account: <*********#yahoo.es> with startDate: <Sun Apr 03 00:00:00 CEST 2016> (ComparisonTerm.GE) and endDate: <Thu Apr 07 00:00:00 CEST 2016> (ComparisonTerm.LT)
Found 5 matching messages (Total messages in folder: 78)
First Message: Mon Apr 04 23:14:22 CEST 2016 --> Mail Subject: Aviso
Last Message: Tue Apr 05 00:48:00 CEST 2016 --> Mail Subject: Alter
//SEARCH SINCE 3-Apr-2016 BEFORE 7-Apr-2016 ALL
Testing email account: <*********#gmail.com> with startDate: <Sun Apr 03 00:00:00 CEST 2016> (ComparisonTerm.GE) and endDate: <Thu Apr 07 00:00:00 CEST 2016> (ComparisonTerm.LT)
Found 92 matching messages (Total messages in folder: 20138)
First Message: Sun Apr 03 04:08:47 CEST 2016 --> Mail Subject: Tu es
Last Message: Wed Apr 06 22:12:45 CEST 2016 --> Mail Subject: ¿Quie
//SEARCH SINCE 3-Apr-2016 OR BEFORE 7-Apr-2016 ON 7-Apr-2016 ALL
Testing email account: <*********#yahoo.es> with startDate: <Sun Apr 03 00:00:00 CEST 2016> (ComparisonTerm.GE) and endDate: <Thu Apr 07 00:00:00 CEST 2016> (ComparisonTerm.LE)
Found 5 matching messages (Total messages in folder: 78)
First Message: Mon Apr 04 23:14:22 CEST 2016 --> Mail Subject: Aviso
Last Message: Tue Apr 05 00:48:00 CEST 2016 --> Mail Subject: Alter
//SEARCH SINCE 3-Apr-2016 OR BEFORE 7-Apr-2016 ON 7-Apr-2016 ALL
Testing email account: <*********#gmail.com> with startDate: <Sun Apr 03 00:00:00 CEST 2016> (ComparisonTerm.GE) and endDate: <Thu Apr 07 00:00:00 CEST 2016> (ComparisonTerm.LE)
Found 20138 matching messages (Total messages in folder: 20138)
First Message: Sat Sep 04 13:23:35 CEST 2004 --> Mail Subject: Gmail
Last Message: Tue Apr 19 10:09:06 CEST 2016 --> Mail Subject: El re
//SEARCH NOT ON 3-Apr-2016 SINCE 3-Apr-2016 BEFORE 7-Apr-2016 ALL
Testing email account: <*********#yahoo.es> with startDate: <Sun Apr 03 00:00:00 CEST 2016> (ComparisonTerm.GT) and endDate: <Thu Apr 07 00:00:00 CEST 2016> (ComparisonTerm.LT)
Found 5 matching messages (Total messages in folder: 78)
First Message: Mon Apr 04 23:14:22 CEST 2016 --> Mail Subject: Aviso
Last Message: Tue Apr 05 00:48:00 CEST 2016 --> Mail Subject: Alter
//SEARCH NOT ON 3-Apr-2016 SINCE 3-Apr-2016 BEFORE 7-Apr-2016 ALL
Testing email account: <*********#gmail.com> with startDate: <Sun Apr 03 00:00:00 CEST 2016> (ComparisonTerm.GT) and endDate: <Thu Apr 07 00:00:00 CEST 2016> (ComparisonTerm.LT)
Found 20138 matching messages (Total messages in folder: 20138)
First Message: Sat Sep 04 13:23:35 CEST 2004 --> Mail Subject: Gmail
Last Message: Tue Apr 19 10:09:06 CEST 2016 --> Mail Subject: El re
//SEARCH NOT ON 3-Apr-2016 SINCE 3-Apr-2016 OR BEFORE 7-Apr-2016 ON 7-Apr-2016 ALL
Testing email account: <*********#yahoo.es> with startDate: <Sun Apr 03 00:00:00 CEST 2016> (ComparisonTerm.GT) and endDate: <Thu Apr 07 00:00:00 CEST 2016> (ComparisonTerm.LE)
Found 5 matching messages (Total messages in folder: 78)
First Message: Mon Apr 04 23:14:22 CEST 2016 --> Mail Subject: Aviso
Last Message: Tue Apr 05 00:48:00 CEST 2016 --> Mail Subject: Alter
//SEARCH NOT ON 3-Apr-2016 SINCE 3-Apr-2016 OR BEFORE 7-Apr-2016 ON 7-Apr-2016 ALL
Testing email account: <*********#gmail.com> with startDate: <Sun Apr 03 00:00:00 CEST 2016> (ComparisonTerm.GT) and endDate: <Thu Apr 07 00:00:00 CEST 2016> (ComparisonTerm.LE)
Found 20138 matching messages (Total messages in folder: 20138)
First Message: Sat Sep 04 13:23:35 CEST 2004 --> Mail Subject: Gmail
Last Message: Tue Apr 19 10:09:06 CEST 2016 --> Mail Subject: El re
From this result we can say the following:
Yahoo returns the proper amount of emails, considering the given Java conditions.
Javamail's request is probably too ambiguous.
#Gmail: given the bunch of conditions in some requests... why you just decide to return the whole folder?
Why is there a different response for the same request?
Who is returning mails right?
Aren't protocols designed to standarise things instead of making it even worse?
We also tried with an Outlook account, with the same result as Gmail.
It sure looks like a bug in Gmail to me. I was able to reproduce it myself. I'm really surprised if Outlook.com has the same bug.
Why do you think the request is ambiguous? The IMAP spec is pretty clear.
A few notes...
Are you sure you're using JavaMail 1.5.5? The SEARCH commands you're showing reflect a JavaMail bug from before 1.5.3.
You should change Session.getDefaultInstance to Session.getInstance.
You don't need the socket factory properties; just set "mail.imap.ssl" to "true" instead.
#BillShannon
I think #popilla20k sees the request ambiguous because when he makes a request with a "GT" AND "LE" searchTerm (andTerm), it is decomposed, for example, as:
//SEARCH SINCE 3-Apr-2016 OR BEFORE 7-Apr-2016 ON 7-Apr-2016 ALL
I must say I've seen a change in Google's behaviour on April 6. Days before, I retrieved all mails that satisfied the condition with "GT" AND "LE" searchTerm. After April 6, I see the same behaviour showed by #popilla20k (using javamail 1.5.5)
Even so, I think the clause OR BEFORE invalids the first one. Does it should be AND clause, isn't? Anyway, days before April 6 the same requests were answered differently than nowadays.
Thanks.
I am trying to parse the HTTP header Date: Tue, 15 Nov 1994 08:12:31 GMT for an HttpServletRequest with a call to request.getDateHeader("Date") but get the following exception:
java.lang.NumberFormatException: Tue, 15 Nov 1994 08:12:31 GMT
at org.mortbay.io.BufferUtil.toLong(BufferUtil.java:106)
at org.mortbay.jetty.HttpFields$Field.getLongValue(HttpFields.java:1479)
at org.mortbay.jetty.HttpFields.getLongField(HttpFields.java:720)
at org.mortbay.jetty.Request.getIntHeader(Request.java:728)
at javax.servlet.http.HttpServletRequestWrapper.getIntHeader(HttpServletRequestWrapper.java:106)
at javax.servlet.http.HttpServletRequestWrapper.getIntHeader(HttpServletRequestWrapper.java:106)
at com.google.appengine.tools.development.ResponseRewriterFilter$RequestWrapper.getDateHeader(ResponseRewriterFilter.java:417)
at com.example.ExampleServlet.doPost(ExampleServlet.java:93)
What am I doing wrong? The sample date is taken directly from the HTTP specification, so I would expect it to be valid under RFC 1123. The servlet is part of an App Engine app (on development server).
This is a known bug in the app engine library. Here is the getDateHeader function at issue, and it clearly calls super.getIntHeader(). It doesn't look like Google is in a hurry to fix it, unfortunately.
I have followed this tutorial http://www.javacodegeeks.com/2012/03/twitter-api-on-your-java-application.html and did the exact same thing. But I am getting an error which is shown below. Am I missing something? Should I be setting some permissions in any file? I have checked in many places but still couldn't fix this. Please help
Exception in thread "main" 401:Authentication credentials
(https://dev.twitter.com/docs/auth) were missing or incorrect. Ensure that you have set
valid conumer key/secret, access token/secret, and the system clock in in sync.
error - Not authorized
request - /1/statuses/user_timeline.json?
TwitterException{exceptionCode=[ced778ef-115a04e4], statusCode=401, retryAfter=-1,
rateLimitStatus=RateLimitStatusJSONImpl{remainingHits=145, hourlyLimit=150,
resetTimeInSeconds=1362901, secondsUntilReset=1235, resetTime=Sun Mar 10 13:15:51 IST
2013}, featureSpecificRateLimitStatus=null, version=2.2.5}
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:185)
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:65)
at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:85)
at twitter4j.TwitterImpl.get(TwitterImpl.java:1895)
at twitter4j.TwitterImpl.getUserTimeline(TwitterImpl.java:254)
at com.jdwb.twitterapi.tweet.main(tweet.java:33)
public class tweet {
public static void main(String[] args) throws TwitterException {
Twitter twitter = new TwitterFactory().getInstance();
ResponseList < Status > a = twitter.getUserTimeline(new Paging(1, 5));
for (Status b: a) {
System.out.println(b.getText());
}
}
}
-------------------------Properties file-------------
debug=true
oauth.consumerKey=***************
oauth.consumerSecret=***********
oauth.accessToken=*******************
oauth.accessTokenSecret=***********************
[Sun Mar 10 14:41:26 IST 2013]status: 401 Unauthorized
[Sun Mar 10 14:41:26 IST 2013]x-ratelimit-remaining: 143
[Sun Mar 10 14:41:26 IST 2013]content-encoding: gzip
[Sun Mar 10 14:41:26 IST 2013]date: Sun, 10 Mar 2013 09:11:26 GMT
[Sun Mar 10 14:41:26 IST 2013]x-ratelimit-reset: 1362908664
[Sun Mar 10 14:41:26 IST 2013]x-transaction: 58f6c286bb1aa6de
[Sun Mar 10 14:41:26 IST 2013]pragma: no-cache
[Sun Mar 10 14:41:26 IST 2013]cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
[Sun Mar 10 14:41:26 IST 2013]{"request":"\/1\/statuses\/user_timeline.json?include_rts=true&include_entities=true&include_my_retweet=1&count=5&page=1","error":"Not authorized"}
Exception in thread "main" 401:Authentication credentials
(https://dev.twitter.com/docs/auth) were missing or incorrect. Ensure that you have
set valid conumer key/secret, access token/secret, and the system clock in in sync.
error - Not authorized
I presume that you have not got your authorization set up correctly
have a look here for how to set up the properties file.
you need to sign up to the twitter dev to get your API keys so that you can fill in the information that you need.