People usually have a tendency to compare their profiles with others, So this is what exactly this app is used for: To compare Twitter profiles. loklak provides so many API’s which serves different functionalities. One among those API’s which I am using to implement this app is loklak’s User Details API. This API actually help in getting all the details of the user we search giving the user name as the query. In this app am going to implement a comparison between two twitter profiles which is shown in the form of tables on the output screen.
Usage of loklak’s User Profile API in the app:
In this app when the user given in the user names in the search fields as seen below:
The queries entered into the search field are taken and used as query in the User Profile API. The query in the code is taken in the following form:
The query return a json output from which we fetch details which we need. A simple query and its json output:
Sample json output:
I am getting data from the json outputs as shown above, I use different fields from the json output like screen_name, favourites_count etc.
Injecting data from loklak API response using Angular:
As the loklak’s user profile API returns a json format file, I am using Angular JS to align the data according to the needs in the app.
I am using JSONP to retrieve the data from the API. JSONP or “JSON with padding” is a JSON extension wherein a prefix is specified as an input argument of the call itself. This how it is written in code:
In this app am also adding keyboard action and validations of fields which will not allow users to search for an empty query using this simple line in the input field.
- Check more about loklak API’s at: http://api.loklak.org/
- Check this and many more interesting apps out at: http://apps.loklak.org/compareTwitterProfiles/ .
- Source Code: https://github.com/fossasia/apps.loklak.org/pull/248/files.