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

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.

Related

Facebook Graph API - Get user profile from conversations

by using Facebook Graph API I can fetch the conversations between users and my page. One of the returned conversations looks like this:
{
"message": "message content",
"from": {
"name": "My Page's Name",
"email": "198301820627381#facebook.com",
"id": "198301820627381",
},
"to": {
"data": [
{
"name": "John Doe",
"email": "396169264164870#facebook.com",
"id": "396169264164870",
}
]
},
"id": "m_mid.$cAADurJ0X8UhnJ3tfxVg9jYXJW5fp"
}
I see that I got the user's id field. How can I fetch this user's profile (first name, last name, profile pic) base on this field ? (or is there another way ?)
I followed the Graph API's User Reference but all I got are the user's id and name (which I already have from the returned conversation).
profile_pic only works for PSIDs (Messenger bot events), for ASIDs just use the picture field instead

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.

Facebook Graph API does not return full post data

I'm using the Facebook Graph API to fetch a public page feed. I created a basic application to get appId and secret. When I make a call to PUBLIC_PAGE_ID/feed I can retrieve the correct list of posts in JSON, but they are missing all the field I need, described in docs, and only have message, created_time and id:
{
"data": [
{
"message": "...",
"created_time": "2015-06-11T07:57:05+0000",
"id": "23X12XXXXXX9836_11XXXXXXXX610XXXX52"
},
...
Why all other data isn't there?
The response to your query: /id/feed is the default response. To access more data, you have to pass a fields parameter with the keyword of data you would like to retrieve.
For example: <id>/feed?fields=id,message,picture,shares
This will return:
{
"data": [
{
"id": "1234567890",
"message": "Message",
"picture": "http://fbcdn.com/xxxxxx.jpg",
"shares": {
"count": 0
}
}
}
What I could figure out is you should submit the app for review with at least one permission what your app still needs and then you will get back every data what you ask in the fields parameter.

How to get gender of users attending some event (Facebook Graph API)?

Is there a way to get gender of facebook users via Facebook Graph API, that are attending some event? Or just by users' ids?
You can consume the events/attending endpoint:
https://developers.facebook.com/docs/graph-api/reference/v2.2/event/attending
Your request would be /{TheEventId}/attending
Which returns a list of user objects:
https://developers.facebook.com/docs/graph-api/reference/v2.2/user
...which looks like this:
{
"data": [
{
"name": "What What",
"rsvp_status": "attending",
"id": "10152412233197215"
},
{
"name": "What What",
"rsvp_status": "attending",
"id": "1682602711966379"
},
{
"name": "What What",
"rsvp_status": "attending",
"id": "10201675684423330"
}
]
You would then need to use the user id to query for each user's details. The user object has a gender field.
{
"id": "10142215948176947",
"gender": "male",
...
}
Also note the permission limitations:
gender & locale can only be accessed if:
The person queried is the person using the app.
The person queried is using the app, and is a friend of the person using the app.
The person queried is using the app, is not a friend of the person using the app, but the app includes either an app access token or
an appsecret_proof argument with the call

Facebook Connect - get users friends score

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)?