I'm building an app that helps you manage your Facebook page rating, read and answer the recommendations directly from the app.
I can access the recommendations as well as answer them without an issue, but I can't seem to access the photos that are posted with the recommendation.
the Facebook recommendation object does not have an accessible "photo" field listed, but the photo posted with a recommendation is an object with an id that can be accessed with the graph API.
My theories:
I don't have the right authorizations to access this object.
I can't access this object from the "recommendation" node, and need to find another connection.
I can't access this object.
the authorization scope I use currently is this:
scope: 'email, pages_manage_engagement, pages_read_user_content, pages_read_engagement',
info_fields: 'email, first_name, last_name',
Related
I would like to know if it is possible to get basic data (name, posts...) of user in Facebook that has public profile (obviously).
I tried with GRAPH API this call:
https://graph.facebook.com/v3.2/USER_ID?fields=id,name&access_token=access_token
When I use my profile USER_ID, it returns my id and my name, but when I put another user ID, it returns this error:
Unsupported get request. Object with ID 'USER_ID' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api
But I reed in documentation that the variable user_id can use in this API call, so I think that this is posible (maybe no).
I reed in other posts, that in the past you can access by username, but now no. Maybe, you only can access to your profile data?
Thanks and sorry about my english.
No, you can not access just anyone’s profile data via API, even if it is shown publicly on the website or the official apps.
The user would need to explicitly login to your app and grant it permission to access their data. Those permissions can not be granted on behalf of someone else - every single user you would want any info about, would have to do this personally.
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
I created a Java program that retrieves users personal information and posts. I can retireve everything related to me but not to my friends.
I know that i have to add some extended permissions to collect information about my friends (e.g. friends_groups, friends_interests, friends_subscriptions and more) but i don't know how to add them.
I didn't use Facebook Api in my Java application. I just give a specific URL, for example :
https://graph.facebook.com/friendID?access_token=MY_ACCESS_TOKEN_HERE
and i get a JSon Object from this URL which contains the information of that user (id, first_name,last_name,link,name,updated_time) which are not useful for what i want to do.
I also tried :
https://graph.facebook.com/friendID?access_token=MY_ACCESS_TOKEN_HERE&scope=friends_activities,friends_birthday,friends_status,friends_subscriptions,friends_work_history
but again it didn't work either to my Java App or Graph Api Explorer.
Can someone explain to me how to add the extended persmissions that i need provided that i created my app in the way i explained above? Can i add the permissions inside the URL that fetches the JSon Object?
To get a person's data, your app needs to use that person's access token. To get that person's access token, that person must authorize your app (through Facebook Login). You can read more about Facebook Login in the documentation.
I am trying to get a list of all users who share a given object on Facebook using the graph api.
There's been some useful info in this regard on stack exchange, here: Getting which users shared a post and here: List of people who shared on facebook
I experimented with the graph api's /{object-id}/sharedposts endpoint on the api. When I make the api call with a given object id which I have verified has been shared over 100 times (according to the /{page-id}/feed endopoint I am getting the object id from for said post), the api result invariably returns as such:
{
"data": [
]
}
So I am getting an empty array...is this because my access token will not allow me to get this information? I am not friends with any of the users sharing the post nor have I 'liked' the page in which the post originates from.
Just wondering if this is an authentication issue or if there's a different problem that I am running into. I've tried it with a few object IDs so I would like to ascertain exactly why there is no data when I use the /{object-id}/sharedposts endpoint.
Thanks!
There was a comment recently added to a response on the List of people who shared on Facebook post you referenced that solved this issue for me.
An access token with read_stream permissions is required, even if you have other permissions like read_insights. I was getting the same results as you until I added the read_stream permission.
However, you still may not get all or any of the shared posts. To see a share, it either has to be shared publicly or you must have permission to view that person's shared post.
We have a Facebook Application with custom Open Graph objects and actions.
We then use a App Access Token to post stories for a particular user from our backend with the normal Open Graph REST API. After the post-call succeeds we log the returned "id" of that post.
Now we would like to collect insight data (e.g. post_impressions_unique) for some of these individual posts/stories using the logged id's.
According to https://developers.facebook.com/blog/post/573/ we should be able to do something like:
https://graph.facebook.com/[POST ID]/insights
Even though this call seems to work using our normal App Access Token, no insight data is returned for the post/story.
Does anyone know if this is possible and how to do it?
We have been experimenting with a normal User Access Token and the "read_insights" permissions, but with no luck. I have read some similar questions but mainly regarding page-posts (this is an App Open Graph post/story).
EDIT:
The facebook article above only refers to "Page" posts. I'm looking for analytics on individual Facebook App Opengraph Posts/stories. It seems difficult to find any good information about this, has nobody attempted this with any success?
You must add insights into a permissions/Extended permissions
Article :
Getting Page Insights
In order to obtain Page Insights via the Graph API, you must use a Page access token, and you must have the read_insights permission. Click on the link below to see this working in the Graph API Explorer.