Facebook Connect - get users friends score - facebook

Hi can someone please tell me (Im using Facebook Connect Plugin for Phonegap) how I can get the users friends scores?
according to multiple sources all you should need to do is an API call to:
facebookConnectPlugin.api( '/me/scores', ['user_friends'], function( response ) {
});
as the current permissions for this app are (from access token debug):
public_profile, basic_info, read_stream, email, publish_actions, user_friends, user_games_activity
but the response I get is always the same:
{
"data": [
],
"summary": {
"total_count": 39
}
}
and if I use /{appid}/scores I get:
{
"data": [
{
"user": {
"id": "147555555555",
"name": "Snowden Luke"
},
"score": 1005,
"application": {
"name": "DFdfdf",
"namespace": "dfdfdfd",
"id": "5205555555583"
}
}
]
}
(its me!)
any help?

According to https://developers.facebook.com/docs/graph-api/reference/v2.1/app/scores#readperms
/{app-id}/scores
returns
Scores from this Facebook game for a user and their friends.
so, this seems to be the right endpoint for you. Concerning permissions, the docs say that
A user access token is required to view scores by that user from the app that generated the token. If the user_friends permission has been granted, it will also returns friends' scores.
Questions:
Are you sure your friends used the same app, and have posted scores?
Are you using a correct Access Token (generated by the same app from whcih the scores came from)?

Related

Facebook graph api unable to get some properties like admin_notes, labels or custom_labels in comments listing

We are building an app that manage Facebook comments for page admins. When managing the comments, we want to know if there is any "admin_notes" or "custom_labels" that the page admin has previously applied on that specific owner of the comment.
I imagine the API is something like this:
https://graph.facebook.com/v3.3/45013343238491111/comments?order=reverse_chronological&fields=message,from{name,id,custom_labels,admin_notes,likes}&access_token=...
The api above should theoretically return list of comments made on a post, with their owners name, id, and custom_labels etc.
But the comment listing response is like this:
{
"data": [
{
"message": "sdfsdfsdf",
"from": {
"name": "Dora Chan",
"id": "23424292416969420",
"likes": {
"data": [
{
"name": "Page name",
"id": "XXXXXX",
"created_time": "2019-05-29T06:03:42+0000"
}
],
"paging": {
"cursors": {
"before": "Mzg5OTgwNzQ4MjcxNzU3",
"after": "Mzg5OTgwNzQ4MjcxNzU3"
}
}
}
},
"id": "450133432384921_450162525715345"
},
{....
Information like "page likes" is available. But information like admin_notes and custom_labels are not available.
Why is that so?
Note:
I am using page access Token. All page related permissions are granted:
manage_pages, pages_show_list, publish_pages, pages_messaging, public_profile
If I call graph API on that specific user directly, i.e. https://graph.facebook.com/v3.3/[userid]?fields=name,id,likes,custom_labels&access_token=...
The outcome is same, I can see only name, userid, likes, but I cannot see custom_labels

Permissions to Read Likes via Graph API

Since the REST API has gone, I need to find another way to read the likes for pages of our webapp.
According to the Graph API docs, the following should return the likes for any object (such as a page):
https://graph.facebook.com/v2.6/{PAGE-ID}/likes?summary=true
Oops, An access token is required to request this resource. Turns out, instead of a real token, you can also build an ad-hoc token witht the app ID and secret:
https://graph.facebook.com/v2.6/{PAGE-ID}/likes?summary=true&access_token={ID}|{SECRET}
The above returns a JSON payload, however, it's empty even though I'm trying this with a page having almost 200 likes:
{
"data": [
],
"summary": {
"total_count": 0,
"can_like": false,
"has_liked": false
}
}
Maybe a permissions problem? The app domain and the page URL domain are identical.
Big thanks for any hints to solve this riddle!
It does work with a simple App Access Token too, but i assume you get the wrong idea about that endpoint. There is no way to get the "Page Fans", you can only get "other Pages the current Page likes" with it. Just try this with your App Access Token:
https://graph.facebook.com/bladauhu/likes?access_token=APPID|APPSECRET
It should return the following JSON:
{
"data": [
{
"name": "FKK Scibes Skulls",
"id": "1391253501090151"
},
{
"name": "Dodgeball Austria",
"id": "387249994631552"
},
{
"name": "Turbojugend Scibes",
"id": "105248832848054"
},
{
"name": "HYDRA! Das endgute Satiremagazin.",
"id": "167084486537"
},
{
"name": "VLÜ Hydra",
"id": "113680962002559"
}
],
"paging": {
"cursors": {
"before": "MTM5MTI1MzUwMTA5MDE1MQZDZD",
"after": "MTEzNjgwOTYyMDAyNTU5"
}
}
}
More information about Tokens:
http://www.devils-heaven.com/facebook-access-tokens/
https://developers.facebook.com/docs/facebook-login/access-tokens/
https://developers.facebook.com/docs/apps/changelog#v2_6_changes:
The likes field on the Page node has been renamed to fan_count
As luschn said in their answer, likes are the other pages liked by that page; if you want to get the number of people that like the page itself, you need to request fan_count.

Is it possible to get user detailed using facebook API V2.6

I am using the "taggable_friends" api to get the list of all friends then uses the user ID (a string of 110 chars) to get user detailes like this:
FB.api('/' + gFriend.id , 'GET',{},
function(response) {
console.log("response",response)
});
In the result I get an error
(#803) Some of the aliases you requested do not exist: {The user Id I have submitted}
Did FB blocked user details API in version 2?
taggable_friends if for tagging only, you can´t use it for anything else and you don´t get a User ID. You only get a "tagging token" that can only be used for tagging. If you just want to create a "friend pic collage", you need to use /me/friends instead. Of course you will only get friends who authorized your app with the user_friends permission.
[from comments] I want to show friend pic collage
The taggable_friends endpoint does return URLs of the friend’s profile pictures already.
You get a data structure like this,
{
"data": [
{
"id": "AaKYNqeDaP…",
"name": "Foo Barski",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p50x50/…"
}
}
},
{
"id": "AaKBGEbAAvYU…",
"name": "Some One Else",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p50x50/…"
}
}
},
So all you need to do is use those URLs provided in the picture structure.

Getting the user context id for a Facebook Open Graph API query

I'm currently building an experimental social network to study the influence of social medias on customers behaviors.
My users log in through Facebook OAuth provider. I store their access tokens and query the Open Graph API to fetch info about them.
I'm trying to use the all_mutual_friends edge for a given user context, using the access token of one of my users, but I found nowhere how to get the user-context-id that is required to get that info.
It is not the id of the user you want to retrieve the mutual friends from. I've tried that and got an error.
I've skimmed trough Open Graph docs and found nothing about that user-context-id.
How can I retrieve it?
Odly enough, the docs do not specify how to get the context id, but I managed to get it by digging a little.
This is how you would do to get the all_mutual_friends data:
GET /{user-id}?fields=context.fields%28all_mutual_friends%29&access_token={other-user-access-token}
Then, the context id would be given in the response.
{
"context": {
"all_mutual_friends": {
"data": [
{
"id": "1381033095543871",
"name": "Dave Amiaaehjighi Putnamwitz",
"token": <user token>,
"picture": {
"data": {
"is_silhouette": true,
"url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xpf1/v/t1.0-1/c15.0.50.50/p50x50/10354686_10150004552801856_220367501106153455_n.jpg?oh=82c2ce067f9c7f2c0a66d1efb16730e7&oe=5670F72F&__gda__=1450287355_17925d7381c8da5663c2349483f4b032"
}
}
}
],
"paging": {
"cursors": {
"before": "MTM4MTAzMzA5NTU0Mzg3MQZDZD",
"after": "MTM4MTAzMzA5NTU0Mzg3MQZDZD"
}
},
"summary": {
"total_count": 1
}
},
"id": <Context id>
},
"id": "1375274282788732",
}
That context id could then be used for
GET /{user-context-id}/all_mutual_friends/
But this step is pretty useless since we get the data in the first query.
Would be nice if Facebook updated their docs to reflect reality.

Retrieve comments on Facebook ads through the API

Is it even possible to retrieve comments on Facebook ads through the API (Graph or FQL)? If yes, do I need a whitelisted app to do it? Also, if I have a page access token, is it enough, or I need a user access token with ads_management permission?
Regarding the token usage, a page_token is extended by a given user to a given app. The page_token will have at most the same privileges as the user on his authorized pages and ad_accounts.
Generating a page_token can be done automatically, in behalf of the user, if you already have a user_token with manage_pages permission. Again, this page_token will have at most the same privileges that the user_token you used to generate it.
In other words, having a page_token doesn't amount for any additional privileges than the ones already present in the user_token.
Having said that, you need
a token with access to a given ad_account
that the app for which that token was generated, has that ad_account active in its settings
If the second requisite isn't met, for example for ad_account act_123456789 you'll get the error:
{
"error": {
"message": "(#274) The ad account is not enabled for usage in Ads API. Please add it in developers.facebook.com/apps -> select your app -> settings -> advanced -> advertising accounts -> Ads API. Account 123456789 not enabled for this application.",
"type": "OAuthException",
"code": 274,
"fbtrace_id": "xxxxx"
}
}
You can try, for example, generating a token with all privileges for the Graph API Explorer App. It will throw the error above because said App doesn't have the ad_account act_123456789 enabled.
So, given you have a token with ads_read extended for an app that has this ad_account listed, and you know the ad_id, you can procede as I explained in thread Get comments from facebook ads (marketing)
Basically, you use the ad_id (for example 123000000) to get the promoted post id and its actions
/123000000?fields=creative.fields(effective_object_story_id),insights.fields(actions)
The answer will contain an effective_object_story_id (for example, let's say it is 456000000_789000000) and its actions broken down by type:
{
"creative": {
"effective_object_story_id": "456000000_789000000",
"id": "123000000"
},
"insights": {
"data": [
{
"actions": [
{
"action_type": "comment",
"value": "12"
},
{
"action_type": "like",
"value": "2"
},
{
"action_type": "post",
"value": "3"
},
{
"action_type": "post_reaction",
"value": "29"
},
{
"action_type": "video_view",
"value": "558"
},
{
"action_type": "page_engagement",
"value": "604"
},
{
"action_type": "post_engagement",
"value": "602"
}
],
"date_start": "2017-08-14",
"date_stop": "2017-08-20"
}
],
"paging": {
"cursors": {
"before": "xxx",
"after": "xxx"
}
}
}
}
If you want to also distinguish paid comments from regular comments, you can query the comments edge of the post_id 456000000_789000000 to get the overall comment count which should be greater than the comments generated by the ad.
You can't pull the actual words of the comment via the API - would make it too easy to scrape.
Yes, Facebook ads that have comments are because the ad is a promoted page post, whether that page post is hidden or not. Page post comments are available via the Facebook API and does not require having Ads API access. Use the graph API endpoint /v2.1/{page-id}/comments to retreive page post comments. See the Facebook Graph API documentation on object comments for more information.