I want to get time line data for 2 users. Currently I am calling getUserTimeline("username",paging) method for both the users and combining the data. Is there any optimal way of doing it, for example, using one twitter api call or is this the only way it can be done? Please help.
As far as I know Twitter APIs does not allow to query for multiple users' timelines.
I guess you already did it, but you should double check that I am not wrong by looking at the official Twitter APIs documentation.
Related
If I want to get recent tweets from a particular user I can do that only using the username in twitter4j
twitter.getUserTimeline(username)
I can also look globally for all tweets that match a search criteria:
twitter.search(new Query(keyword))
Is there a way I can search within all of the tweets from one user's timeline for a particular keyword?
Yes, it's possible using the Twitter Search API but the caveat is that it will only return tweets going back 7 days.
The Twitter Search API is part of Twitter’s REST API. It allows queries against the indices of recent or popular Tweets and behaves similarly to, but not exactly like the Search feature available in Twitter mobile or web clients, such as Twitter.com search. The Twitter Search API searches against a sampling of recent Tweets published in the past 7 days.
Before getting involved, it’s important to know that the Search API is focused on relevance and not completeness. This means that some Tweets and users may be missing from search results. If you want to match for completeness you should consider using a Streaming API instead.
To use the Twitter4J API search(query) the query would be from:<username> <keyword>.
The Streaming API can be used for search but would not really apply as it's designed to return large amounts of tweets from many users at that moment.
The thorough approach would be to go through every tweet on a user's timeline and do the search yourself. This would be much more involved but not that hard actually.
You would use the GET statuses/user_timeline API (getUserTimeline() in Twitter4J) and then search your keyword in the text field.
According to the answer in here, using Gson we can programmatically achieve to retrieve the result that Google will return to a query. Nonetheless, yet there are 2 questions are remaining in my mind:
How can we do similar thing for Bing?
How can we get more than 4 results based on the referred answer? Because the results.getResponseData().getResults().get(n).getUrl() for n>4 returns exception.
As #Niklas noted, google search api is deprecated, thus you should not use it for your project. Currently the only solution would be to get search result by http request to get a html search results and than parse it yourself.
In case of Bing, there is a search API, but it has a limited number of calls for free users. If you need to make a lot of requests, than you will have to pay for it. https://datamarket.azure.com/dataset/5BA839F1-12CE-4CCE-BF57-A49D98D29A44
I have to implement custom search in my application for android 2.3.I have some EditText in which user type one letter and then I send response to the server, retrieve all the results matches this one letter and then I need to display them in a list. When user types second button I also need to send new response and refresh data and so on.
The question how can I do this in Android 2.3? What should i use?
This seems to be too open ended with too many questions to give a really helpful answer.
What you use in your app will heavily depend on how the server's API is expecting you to communicate. I, for one, am all for hiding the specifics of what a server does from the application and put all the "smarts" behind the API. So a query like:
http:/blah.com/getresults?search=a
would result in whatever matches 'a'. If it is searching a MySql Db, processing a Google search, or accessing files on the system doesn't matter.
Your code needs to worry about the interface to the API to make queries and processing the results, whether they're free formatted text, JSON objects, or whatever.
Maybe rewording your question or provide information on what you know would help.
I am searching for free event sources that I can use within my java-application.
I am looking for something similar to YahooFinance, where one can query a bunch of stock info and retrieve the result as csv.
Ideally, an API or a URL with some query string would be perfect.
How about SuperFeedr?
You could also run some SPARQL-query on some SPARQL-Endpoint and "feed" the result back to your application. Here is a list of some endpoints (here including uptime and availability stats).
Twitter also offers an Streaming-API, where one can listen for status changes etc. Another way could be to implement some HTML-crawler that extracts interesting facts from webpages, but that's probably not what you are looking for...
Kind of related:
Flickr API - observe activities on flickr
SO - Cricket API
for this you can use Rss4j api which provide both read feed and also create you own feed.
hope this will help you
I'm working on a project which uses Facebook Graph Api to download information about users of our application and their Facebook friends. There is a need to update this data, but as I understand Real-Time Update is not an option. For example I would like to have update of profile feed of friends of our app user, and I don't see a way to do this with Real-Time Update.
Could someone give me some advice on this update mechanism? I need to update app users, their friend connections and profile feeds of users and their friends. I understand I'll have to poll Facebook servers to retrieve this data. What I'm trying to find out is some good practices when doing these things. Update frequency? Way to recognize that data has changed? If anyone has experience with this kind of things every advice would mean a lot.
Thanks.
You can use the since= query string parameter of the Graph API call. Here's some pseudocode to help you along
var usersLastPostDate = GetLastPostDateFromDataStore(userId);
if(usersLastPostDate not populated) {
streamItems = GraphApiGet(userId, "me/feed")
lastStreamItemDate = GetNewestStreamItemDate(streamItems)
StoreLastPostDateIntoDataStore(userId, lastStreamItemDate )
}
else {
streamItems = GraphApiGet(userId, "me/feed?since=" + usersLastPostDate )
}
Not massively useful for your use case (as you're wanting to get data which changes frequently), but worth pointing out that the Graph API now supports ETags - https://developers.facebook.com/blog/post/627/.
ETags will tell you if the data has changed since the last time you requested it. This won't stop you from hitting Facebooks API throttling limits, but is a quick and easy way to tell if the data has changed since you last asked for it.
There is no one answer to your question, as it depends on what your application is doing. How often do you need to get the updated information? If your data is stale for 5 minutes, is that really a problem? Can you grab the data from Facebook lazily, when some user action requires that you have it?
If you do need to do a lot of polling try and use non-blocking IO, especially if you're expecting to have a lot of open HTTP requests to Facebook whilst you're polling. Build a reliable queueing mechanism and HTTP poker to ensure requests are being made as expected. Without any idea of what technology stack you're using it's hard to be more specific than that.
HTH
What about this: Open Graph Subscription system ?