Android: working with the Twitter search api - android

I'm working on an Android app that works intensively with the Twitter search api, retrieving twitts that contain certain keywords, and then tokenizing other words in them. My question is the following: form an architectural point of view, is it better to do all the work inside the app or to retrieve the information from a webservice? (I was considering this last option at f
first, but I'm afraid that even caching the results wouldn't be enough to bypass the limit rates of the Twitter api).

Related

Facebook new feed API access

I'm currently building an Android app that makes use of the Facebook API. I've gotten to the stage where I want to be able to retrieve a user's Newfeed i.e. the one you see at https://www.facebook.com/home.php. It seems that was possible using the /{user-id}/home endpoint but of course, that's now depreciated and they suggest using /{user-id}/feed but it seems entirely different since the home endpoint states
returns posts a person sees in their News Feed
however the feed endpoint states
links published by this person, or by others on this person's profile
which suggests the user's timeline instead.
Was that the only was of retrieving the newfeed? And is there any new endpoint I can use? I've tried looking already but it seems getting the user's newsfeed is no longer possible, is that correct?
Use feed. It's basically a replacement for home, but yes, it only gets the posts they are tagged in and such that would appear on their timeline.
They removed the functionality you're looking for when they removed home.
Documentation.

How to search twitter.com/search and parse the data in android

I have been dealing with a twitter application in android. I used Oauth authentication and did some search for a given keyword.
The problem is rate limit. I can't perform to many searches.
Well after an exhaust search I came across with that link:Using the Search API
It says that:
As users, the best thing for you to do is perform your search from twitter.com/search
Then I found an application in Google Play Twitter Search which doesn't even use authentication and performs unlimited searches.
I doubt Twitter Search developer has used that logic.
Would it be possible to make the search directly from twitter.com/search ?
If yes, what libraries/methods/ways should I follow?
Would it be possible to make the search directly from
twitter.com/search ?
Technically yes, but that should be avoided if at all possible. You would have to parse the HTML and that is a both slow and error prone process.
What libraries/methods/ways should I follow?
You should stick to the official API. I realise that this rate limit is kind of in the way, but I am confident you can mitigate the problem by reducing the overall amount of calls to the API and by more efficiently using each call. You have to remember that this is the official Twitter API. Twitter certainly wants for Twitter apps to be good and awesome and while the rate limit of 100 calls per hour seems pretty low it should normally be more than enough. Should the rate limit be reached anyway you just need some proper error handling. I know for a fact that most third party twitter apps just kind of freeze their content when reaching the rate limit. An error is displayed to inform the user that he cannot update anymore for an hour, but he can still continue using the app as before with all the cached data from the previous calls.
Since you haven't posted any code I am not sure what else to tell you just try to be smart about each call. Use cached data as much as possible and only perform API calls when absolutely necessary.
EDIT: I think parsing data from https://mobile.twitter.com/search would be best in your case. Just look for the div with the class timeline. Every <table /> in this div contains one tweet. It shouldn't be that difficult to parse.
I tested it using HtmlCleaner:
HtmlCleaner cleaner = new HtmlCleaner();
TagNode root = cleaner.clean("https://mobile.twitter.com/search?q=asdf");
... // Filter out div with class "timeline"
List<? extends TagNode> tweets = timeLineDiv.getElementListByAttValue("class", "tweet", false, true);

Facebook API to do sentimental analysis

I am developing an android native application for sentimental analysis. The context is I need to get the information from the social media like Twitter and Facebook. I have done it for Twitter by using the API to get the 100 latest tweets about the particular organisation. That is fine.
Now I am trying to do the same for Facebook. Is there any free API available for this sentimental analysis.
I'm assuming to get the Twitter analysis working you used their 'firehose.'
If that is the case, and you're looking for a Facebook equivalent: it doesn't exist. Perhaps it's because the dynamics of these two social networks are not exactly identical and so what each is trying to achieve is different.
While some Facebook users' activities can be completely public (as per their choosing), most of the content is behind walls, so to speak. So unless you scrape the public info and do some analysis on it, as of right now there is no API support for what you're looking for.
If you're doing it for a particular organization they probably have a facebook page. Since almost all pages are public you can use the Facebook API to to query that page and get all the comments from that page. Once you have those comments you can perform sentiment analysis on them. The query might look something like:
$facebook->api("pageName/posts?fields=created_time,id,message,story,type,picture,shares,likes,comments.limit(5000)");
The above example is in php but you can find an equivalent Java example.
Since there is no stream like functionality for Facebook you would have to set, maybe a cron job, to run it every hour to get the latest comments.

Is there a way to pass a variable to an aspx file via the url?

I am trying to write a little Android app for my daughter. The goal is to scan a book's bar code and pass the ISBN number to this website: http://www.arbookfind.com/default.aspx . The result will show if the book is part of the Accelerated Reader program and how many points the book is worth. I am trying to automate the part where the ISBN would need to be entered into the search field.
For simplicity's sake, and because I'm not a programmer, I am using MIT's App Inventor 2. I can now scan and get the ISBN but I will need to know how to format a URL to the website that will allow me to pass the ISBN to it's search page.
Is it possible to send a variable via the URL similar to index.php?myvar=testing&someothervar=somethingelse ? I've tried but perhaps I am not using the correct variable name or format for aspx. Is there an easy way to see what the variable name is in the aspx displayed page in my browser?
EDIT To clarify, I am not trying to scrape data and avoid showing ads from the site I am using to generate the results. I am wanting to pass the ISBN number to the page and have it search and display the resulting page in the phone's browser. I am also fine with a method that would populate the search field and the user would have to hit the search button if that can be accomplished easier.
I would recommend abandoning this route, as it is highly unlikely that the owners of this website will want you passing a query string to their site anyway, but rather they will most likely point you to an Application Programming Interface (API) that they provide, so that your program can connect to this service (free or paid, depending upon the company) and then you can request the book's details by providing the ISBN in the request.
There is no discovery mechanism for an .aspx page like there is for a web service to find out the names of things to pass. Even if you figure out what the name of the query string is that you could pass in for ISBN, you run the risk of the implementation being changed and your "application breaking". While this is also true of web service APIs, since APIs are the route the website providers want you to use, as opposed to screenscraping, then they generally inform their users of breaking changes or newer versions of the API via documentation.
From what I can see that page does not accept URL-variables for their search field the way google.com and other does. The page is generated through some sort of content management system (CMS) and it relies heavily on javascript to make things work. I tried doing a normal search there, and you have two issues you need to wriggle around.
First, the page redirects you to a page where you select if your a student, parent etc. It seems that it relies on some session cookie to remember the setting, but it times out pretty fast.
Second, the form uses javascript to trigger the search, and it appears to be done using AJAX, a method of using javascript to trigger actions on the server and displaying the results, without actually loading the page again. You might be able to get a hold of the javascript code used and re-engineer it for your purposes, and call that using HTTP POST and/or GET from your app, but it is a tricky path, and quite possibly not allowed by the company since you will be loading data from their site, without presenting their advertisements and thus be costing them money.

Challenging other players using Facebook API with the same data

I'm in course of developing an application, which basically is a quiz. I store all the questions on an external server, and fetch them as JSON files. I'd like to implement some Facebook features, most importantly the possibility of challenging other players. However, in order to compare the results, I'd like that other user to use the same set of questions in a current game, as I do - situation similar as in SongPop, where two players guess the same songs. I'm not sure though if it's possible for a standard Android app, not Facebook app like SongPop. I'm looking for a way of somehow sending a 'data pack' to him, containing the questions I have for the current challenge.
Create a Question Set which is a collection of Questions.
e.g. QuestionSet1 will contain Question2, Question4, Question5.
You can just send QuestionSet1 to the user being challenged. e.g. mysite.com/game/?questionsetid=1
On your server, if the url contains the parameter 'questionsetid', that meets you'll get the questions from the Question Set.

Categories

Resources