-
Notifications
You must be signed in to change notification settings - Fork 57
Home Page and My Feed
#Feed
The Home and MyFeed Module consists of :
- Fetching the posts of corresponding Facebook page using Facebook Graph API
- Showing detailed description, image, number of likes and created date of the post.
- Show high quality image.
###1. Fetching the posts The Facebook posts are fetched by creating an Http GET Request to Facebook Graph API in an async task. This gives 10 posts.
private class DownloadWebPageTask2 extends AsyncTask<String, Void, String> {
String id;
...
@Override
protected String doInBackground(String... urls) {
Log.e("Yo", "Started");
String URL;
URL = "https://graph.facebook.com/"+id+"/feed?limit=10&fields=picture,shares,message,object_id,link,created_time,comments.limit(0).summary(true),likes.limit(0).summary(true)&access_token=" + Val.common_access;
Log.e("this2",URL);
HttpClient Client = new DefaultHttpClient();
HttpGet httpget = new HttpGet(URL);
ResponseHandler<String> responseHandler = new BasicResponseHandler();
try {
text2 = Client.execute(httpget, responseHandler);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
...
}
The next 10 posts can be obtained by calling the url in "next" field of the JSON response.
###2. Displaying required information
A Http GET request is executed and the response is stored in the variable 'text2'. The response of JSON format is given as something like this.
The JSON string is then parsed to get the required fields and the values are added to the lists.(in postexecute of function of DownloadWebPageTask). These are then displayed in proper format by the list view adapters
###3. Displaying high quality image
To fetch high quality image from facebook graph api, the http get request is made to the following url :
https://graph.facebook.com/_object_id_?fields=images&access_token=_access_token_
which gives json response in this format. The image url of reuired image resolution is then obtained. The final high quality image is shown in Image Activity using this.The widget used to display image is TouchImageView which provide gestures to zoom and unzoom the image.
This documentation is written by Swati Garg, drop in a mail at swati4star@gmail.com for any queries
For any sort of questions/doubts you have regarding the documentation, please contact Swati Garg at swati4star@gmail.com.