As you know that Facebook upgraded it API to V3.1 and now killing old APIs and Apps slowly so we have to migrate on there new API where they took some hard decision that is good on SPAM site but hard for developers too.
Reminder: Graph API v2.7 will be deprecated on Oct 05, 2018. Please use the API Upgrade Tool to understand how this might impact your app. For more details see the changelog
Now I created a new FB app with some settings as shown in the below screenshots to Post On My Own Pages not Profile but got errors that is mentioned below too.
And then I used the below code to post on my own page where I am Owner from same account where I created this Apps.
<?php
$page_access_token = 'GENERAL_ACCESS_TOKEN';
$page_id = 'OWN_PAGE_ID';
// From https://developers.facebook.com/tools/explorer
$data['message'] = "Text_Message";
//$data['picture'] = "http://www.example.com/image.jpg";
//$data['link'] = "http://www.example.com/";
//$data['caption'] = "Caption";
//$data['description'] = "Description";
$data['access_token'] = $page_access_token;
$post_url = 'https://graph.facebook.com/'.$page_id.'/feed';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$return = curl_exec($ch);
echo $return;
curl_close($ch);
?>
Now when I run upper code, I got the below error...
{"error":{"message":"(#200) Requires either publish_to_groups permission and app being installed in the group, or manage_pages and publish_pages as an admin with sufficient administrative permission","type":"OAuthException","code":200,"fbtrace_id":"XXXXXXXXX"}}
Now my question is from where I can allow my Apps these permission because where I allowed all didn't see these names (publish_to_groups
, manage_pages
and publish_pages
etc) as shown in the above last screenshot.
Note: Everything I created and Code now so I need solution working with newly released API 3.1.
UPDATE:
My friend told me to allow all permission to get my code working as shown in the below screenshot but I am not able to view these permission in my apps. I need all these. How to get them?
I tried many things and then I found it on Facebook Developers Guide that after new Update, No one can get all of the below showed permission if the Apps goes Live. To get all these permission after making your Apps live, you have to Apply for permissions to review or else you can get all permission freely in Development Mode But it will work for you only.
As you know that to get all permissions in your Apps for your own use, you can get it without Reviewing your apps or anything. You can see a General Setting of an Apps below.
You just have to turn your apps in development mode by turning the live mode off as shown in the below and upper screenshots.
After doing this, just go to Graph API Explorer and click "Get Token" button then select "Get User Access Token" and here you will get the pop up as shown in the first screenshot of this Answer where you can select your desired scopes and click "Get Access Token". It will raise a POPUP where it will need your permission to allow and then it will return you the Access Token. (You Can Extend Your Access Token To 60 Days)
Note: This token will post on your Page will be visible to you only because your Apps is not live so every activity done by your apps is for you only.
It's seems to me that you are using a user access token. To get a page access token you should call the endpoint:
to get the list of pages and the access tokens for each of them.
Or:
if you already know the page where you want to post.
When you obtain a page access token you can call the
feed
endpoint.Take a look here: https://developers.facebook.com/docs/pages/access-tokens