Assign admin role for facebook page over FaceBookGraph API - facebook

I have facebook page and I am admin of that page. Now I want to assign admin role to some one from my friend list using Graph API.
In docs i found how i can list admins of one pege ussing accounts parametar, but i can't found how i can add some one to be page admin.
Thank you in advance.

Nope, Its not possible.
Just think about it. If its allowed, then wouldn't any fb app start taking over your pages?
Also, If you want to manage fb page, then you can easily do that via their API, it allows everything one can do if they were an actual admin of the page.
Example: Status Update, Wall Post, Photo Upload, Events Management (Create/Invite), Comment, Like, Insights, etc. What else you need?

If you POST to the graph /{pageID}/admins?access_token={Page_access_token}&owner_email={some user emai} then you get this response from the server: "error": {
"message": "(#100) Your app does not have the permissions to modify admins",
"type": "OAuthException",
"code": 100
So if they say that my app does not have the permission to modify admins it is logic that some apps may have the permission, tome tokens. The problem is that the required permission code is not public on the API documentation.

I was able to add an admin via Graph API using Koala library for Ruby like this;
#page_api.put_connections('your page id' , 'roles', {'admin_id' => 'user id from your friend list'})

Related

How to get my own Facebook user timeline using Graph API?

I would like to get all the posts and updates that are normally displayed in FB official application for MY account (this includes updates from my friends and liked pages).
I wasn't able to find any details how to get that, the only thing I've managed to get is my own posts.
Anyone got any experience with that using current Graph API verion (3.3)?
All the alternate FB clients (ex. Friendly) must be doing this somehow.
There is no way to get ANY data of users who did not authorized your App. Which means, there is no way to get posts of friends. You can only get your own friends, with the user_posts permission and the /me/posts endpoint. If some Apps access friend data without their authorization, they are most likely doing something that is not allowed.
Here is what I found in their API docs:
There are two scopes:
The user feed requires the user's permission
The public feed has fewer capabilities but doesn't require perms

Facebook business manager to use Page API

For those that will read it, thank you very much (and special thanks for helpers).
We're having some trouble with Facebook, and we're not sure if it's related to Facebook latest scandals.
Facebook forums are not the most responsive, so I thought to give it a shot here.
The goal is to read posts from our customers pages.
We thought that to create Business Manager with system user, ask our customers to add us as partners to their pages, generates page tokens and use the {page_id}/feed API.
In order to test this flow, we did the next steps:
created BM
created Facebook Page (via the BM)
created an app
associated the app with the BM.
in BM settings page - created System User.
assigned the system user with the created page (admin role)
generated token (related to the app created).
using Graph API, called to me/accounts (with the access token given at 7).
I verified that the page id was in the response, and took the access_token from the response.
tried to call {page_id}/feed (or to /me).
This is the error I received:
{
"error": {
"message": "(#10) To use 'Page Public Content Access', your use of this endpoint must be reviewed and approved by Facebook. To submit this 'Page Public Content Access' feature for review please read our documentation on reviewable features: https://developers.facebook.com/docs/apps/review.",
"type": "OAuthException",
"code": 10,
"fbtrace_id": "BV/3aru6KTJ"
}
}
Thanks for anybody that helps.
seems you have go far:
take a look from the image and put some details to be approved after that you have to submit it. approval will take time just be patient.
App Review-> Add Items-> Page Content Access.. hopefully the rest instruction from developer.facebook.com will be understandable.
for those newbies just take a look how to start an app.
https://developers.facebook.com/docs/apps/register

How do I manage a users facebook "managed pages"?

I am currently working on a project where we want to post to a users facebook wall or the wall of one of a users managed pages.
See this page: https://socialiteproviders.github.io/
Note that facebook is not listed! Weird being it is one of the top social networks, why is it left to be a custom, override provider?
return Socialite::with('facebook')->scopes(['publish_actions', 'manage_pages', 'pages_show_list'])->redirect();
and then
$user = Socialite::driver('facebook')->user();
Where can I find documentation on socialite in regards to facebook? Specifically how do you get the information on managed pages for the user who just logged in.
We do have app permission from facebook. When you link your account, on the facebook page it pops up asking to give permission to the app to manage pages.
When I dd() the results of ->user()
I get
token, refreshToken, expiresIn, id, nickname, name, email, avatar, user -> [name, email, gender, verified, link, id], avatar_original, profileUrl.
If I understand correctly, there should be a way to get a "data" attribute that contains information on managed pages.
see this link: https://developers.facebook.com/docs/pages/access-tokens#multiple-pages
Am I going to have to work directly with the Facebook API, or is there a way to get this information out of socialite?
Thanks!
EDIT:
I was asking additionally about a facebook provider, and whether it was hard coded into socialite. I have since posting this foind in vendor/laravel/socialite/SocialliteServiceProvider.php is actually wired up for facebook. I still however, cannot figure out how to manage a facebook users "managed pages"
You are close, in my opinion.
As you can see in the Facebook API Documentation, to give your application the ability to publish in a page that the user manages, you need to ask for manage_pages y publish_pages permissions.
On the other hand, by default Socialite will ask Facebook for the most common fields (like id, email, name, etc) but to get extra -driver specific- fields you need to specify them too. So this should do it:
return Socialite::
with('facebook')
->scopes(['manage_pages', 'publish_pages', 'the_rest_of_your_scopes'])
->redirect();
And to retrieve the user:
$social_user = Socialite::
driver('facebook')
->fields(['accounts', 'some_other_extra_fields'])
->user();
Disclaimer: I haven't test it yet, but this should include an accounts key in the user object that will have an array of the user page(s), his/her role(s), page info and the token to perform actions in the page (yes, like publish).
I hope this can serve you as a guide at least. Good luck.
If you check the following Official Laravel Socialite Pacakge
(Use this Package )
https://github.com/laravel/socialite
Facebook providers are there already.
Get the access token from Facebook
Save it to database
Use the graph API of facebook to access page details.
Send the saved access token with api requests
Alternatively you can use this package too.
https://github.com/SammyK/LaravelFacebookSdk

How to get any user posts using facebook Graph API?

I only can reach to my posts with API but I can not reach to friends posts so I want to fetch all the public posts from a user with my user access token.
to be clearer I want to get the users post AND his friends posts.
You can't. For privacy reasons, the Facebook API won't give you most information unless the user who owns that information - not their friends, even if it's technically part of the "public profile" - explicitly grants permission by connecting to your application with the right permissions.

Graph API sharedposts edge empty data issue

I'm facing a problem with /sharedposts edge it keeps returning empty array
{"data": []}
I'd like to share my case exactly with you, may be I'm doing something wrong.
I'm using Graph API Explorer / API ver 2.3
I'm trying to track a fan page post, and get the users' ids who shared this post
The page post is public
All the sharing is public too
My application has read_stream permission granted (at least on the testing users)
I even tried that when I'm the page Admin, App Admin, and I did the sharing myself to my timeline, all permissions are granted and I added manage_pages permission.
I tried using the {post_id}/sharedposts
I tried using the {page_id}_{post_id}/sharedposts
Based on other posts in this regard on StackOverflow, I added limit.
All the above trials, keep giving me the same results
{"data": []}
Please advise me what's wrong with my App, please if anybody has a successful experience with this issue please share, or advise me where could I find the problem?!!!
There seems to be a known bug with this API endpoint. The behaviour you're describing is the same as in this bug report: https://developers.facebook.com/bugs/1404733043148335/
The /sharedposts endpoint will -only- retrieve posts from users who have -also- granted your app. This means that even though a post might be public on a users' timeline, unless they have also granted your app permissions, you will not be able to retrieve that post.
For example: a user posted to a page and the post is public. This post can be retrieved with an access token. Let's assume that the user also shared this post to their own timeline. But, since the user has not granted permissions to your app, you will not be able to see this post using the /sharedposts edge on the original post (on the page). This also holds if the user shared their post publicly to his timeline.
This behaviour is by design; the API is more restrictive in returning user data than the website is. This holds for multiple endpoint and this is one of the examples where it is the case.