Embed activity feed of a public Facebook page without forcing user to login/allow
To get the activity feed of a public Facebook page, like White Collar, follow these steps:
1) Get your App-id and App-secret by choosing an existing app or creating a new one at this url:
https://developers.facebook.com/apps/
2) Get an access token by making a GET request to this url:
https://graph.facebook.com/oauth/access_token?client_id=" + APP_ID + "&client_secret=" + APP_SECRET + "&grant_type=client_credentials
3) Get the page-id of your fan page. To do this, you need the page-name. Go to your fan page on facebook and look at the url. It will have this form:
https://www.facebook.com/{fan-page-name}
Once you have that, make a GET request to this url:
https://graph.facebook.com/{fan-page-name}?access_token={access-token}
It will return a bunch of JSON. You're looking for the first "id" element. This is your page-id.
4) Get the fan page JSON data with a GET request to this url:
https://graph.facebook.com/" + page-id + "/feed?access_token=" + URLEncoder.encodeUTF8(access-token)
To avoid having exceptions thrown, I had to use URLEncoder.encodeUTF8().
The data you're looking for is under the "data" element.
I wasn't able to find anything that would do the JSON parsing of the Facebook feed for me, but I did find this tutorial that will do a lot of the formatting for you to make it look like Facebook.
Hope that helps anyone else trying to do this.
Is there any way I can get public feed of some user or application without logging in, using Android?
There are 2 ways of doing this:
1) Using App id and secret get access token (no user interaction), and then use it to access feed:
try {
String APP_ID = "123123123123123123";
String APP_SECRET = "0123456789abcdef";
String OWNER_OF_FEED = "barackobama";
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(
"https://graph.facebook.com/oauth/access_token?client_id="+
APP_ID +
"&client_secret="+APP_SECRET+"&grant_type=client_credentials");
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String access_token = client.execute(get, responseHandler);
// access_token contains sthing like "access_token=XXXXXXXXXX|YYYYYY" ,
//need to replace pipe (this is ugly!)
String uri = "https://graph.facebook.com/" + OWNER_OF_FEED + "/feed?"
+ access_token.replace("|", "%7C");
get = new HttpGet(uri);
String responseBody = client.execute(get, responseHandler);
// responseBody contains JSON-encoded feed
textview.setText(responseBody);
} catch (Exception ex) {
ex.printStackTrace();
}
2) Using RSS feed:
http://www.facebook.com/feeds/page.php?format=rss20&id=6815841748
... in case you wonder: 6815841748 is a Facebook ID of president Obama, Google will tell you how to get it.
How do I get the Public Feeds from our Fanpage without forcing users to accept an app
If you are an admin on the fanpage, you can provide yourself with a page access token that has been extended indefinitely through Scenario 5 https://developers.facebook.com/roadmap/offline-access-removal/ and set that in the PHP SDK while saving it to the database $facebook->setAccessToken('PAGE_ACCESS_TOKEN');
When a user grants an app the manage_pages permission, the app is able to obtain page access tokens for pages that the user administers by querying the [User ID]/accounts Graph API endpoint. With the migration enabled, when using a short-lived user access token to query this endpoint, the page access tokens obtained are short-lived as well.
Exchange the short-lived user access token for a long-lived access token using the endpoint and steps explained earlier.
https://graph.facebook.com/oauth/access_token?
client_id=APP_ID&
client_secret=APP_SECRET&
grant_type=fb_exchange_token&
fb_exchange_token=EXISTING_ACCESS_TOKENBy using a long-lived user access token, querying the [User ID]/accounts endpoint will now provide page access tokens that do not expire for pages that a user manages. This will also apply when querying with a non-expiring user access token obtained through the deprecated offline_access permission.
An example can be seen at
http://philippeharewood.com/facebook/getting-your-facebook-page-on-your-website-with-access-tokens/
Get wall feed from a public Facebook page using Graph API - is it really this complex?
Two years later, you can programmatically do this with a Facebook App (an example using PHP and Slim): https://developers.facebook.com/apps/
$base_api="https://graph.facebook.com/";
$client_id="XXXXXX";
$app_secret="XXXXXX";
//get a profile feed (can be from a page, user, event, group)
$app->get('/feed/:profileid/since/:start_date', function ($profile_id,$start_date) {
$start_time=date('m/d/Y h:i:s',$start_date);
$request = new FacebookRequest(
getSession(),
'GET',
'/'.$profile_id.'/feed?since='.$start_time
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
//do something with $graphObject
});
function getSession(){
$session = new FacebookSession(getAccessToken());
return $session;
}
function getAccessToken(){
global $base_api, $client_id, $app_secret;
$url=$base_api."oauth/access_token?client_id=".$client_id."&client_secret=".$app_secret."&grant_type=client_credentials";
$str = file_get_contents($url);
$token = str_replace ( "access_token=" , "" , $str );
return $token;
}
How to show facebook feed messages from my site without access_token?
I don't think you can do it without the access token anymore, but check my answer here for detailed steps on getting one and retrieving the feed you want.
Get the post feed of a public facebook page
I ended up finding something that wasn't quite what I was looking for, but still got the job done: Facebook Page Plugin
It lets you embed the publicly available feed of a Facebook page into a web page. If you want to use it in an app you can host the web page that has the feed code in it and then load it into a web view in the app.
get facebook news feed from different sites in android app
Please refer the below posts; you would get answer for your question!
Embed activity feed of a public Facebook page without forcing user to login/allow
Get public page statuses using Facebook Graph API without Access Token
Can you get a public Facebook page's feed using Graph API without asking a user to allow?
https://developers.facebook.com/docs/graph-api/using-graph-api
Related Topics
Limitation on Texture Size? Android Open Gl Es 2.0
Gradle 0.9.+/0.9.2 Error: Unable to Load Class 'Com.Android.Builder.Testing.Api.Deviceprovider'
How to Fill Recyclerview with Gridlayoutmanager from Right to Left
Android Design Considerations: Asynctask VS Service (Intentservice)
How to Run (Not Only Install) an Android Application Using .Apk File
How to Stop Scrolling in a Gallery Widget
Android Translate Animation - Permanently Move View to New Position Using Animationlistener
Android - How to Display a Dialog Over a Native Screen
How to Use Broadcast Receiver in Different Applications in Android
Android.Os.Networkonmainthreadexception . Need to Use Async Task
Out of Memory Error While Loading Bitmaps
Failure [Install_Failed_Update_Incompatible] Even If App Appears to Not Be Installed
How to Allocate These Folders in Another Place