I am developing a simple java program to post automatically (articles) to my facebook fun page. I have created an app and have got an access_token using url : https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=APP_ID&client_secret=CLIENR_SECRET. I use this java code to post to fun page wall :
String url = "https://graph.facebook.com/" + PAGE_ID + "/feed"
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("access_token", accessToken));
nvps.add(new BasicNameValuePair("message", item.getTitle()));
HttpClient client = new DefaultHttpClient(params);
HttpPost httpost = new HttpPost(url);
httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
HttpResponse response = client.execute(httpost);
HttpEntity entity = response.getEntity();
I got this error:
{
"error": {
"message": "(#200) The user hasn't authorized the application to perform this action",
"type": "OAuthException"
}
}
How can I give my app authorization to post to my fun page ? thanks in advance
following recommendation of
Wow, I see this same question asked at least once a day.
You will want to ask for manage_pages
and publish_stream
. Once the admin of the page authenticates, query me/accounts
and grab the page's access token from that list. Using that page's access token, then you can post to me/feed
.
simple, u just need to ask permissions..that's it..
String[] permissions = { "offline_access", "publish_stream", "user_photos", "publish_checkins","photo_upload" };
mFacebook.authorize(MainActivity.this, permissions,
new LoginDialogListener());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With