Missing access_token attribute for child pages - facebook

I'm requesting child pages from a specific Page and I'm explicity requesting the access_token on fields but the response doesn't include the requested attribute.
Can someone help me understanding what's going on?
First of all I request the pages from an account through /v15.0/me/accounts endpoint:
https://graph.facebook.com/v15.0/me/accounts?access_token=[FILTERED]&fields=id,name,has_transitioned_to_new_page_experience,access_token
And here's the output:
{
"data": [
{
"access_token": [FILTERED],
"id": "10[...]80",
"name": "Lorem Ipsum",
"has_transitioned_to_new_page_experience": true
}
],
"paging": {
"cursors": {
"before": [FILTERED],
"after": [FILTERED]
}
}
}
Using that same id I then try to get all the child pages from that Page using /v15.0/OBJECT-ID/locations:
https://graph.facebook.com/v15.0/10[...]80/locations?access_token=[FILTERED]]&fields=id,name,access_token
{
"data": [
{
"id": "16[...]55",
"name": "Lorem Ipsum"
},
{
"id": "10[...]68",
"name": "Lorem Ipsum"
}
],
"paging": {
"cursors": {
"before": [FILTERED],
"after": [FILTERED]
},
"next": "https:\/\/graph.facebook.com\/v15.0\/10[...]80\/locations?access_token=[FILTERED]&fields=id%2Cname%2Caccess_token&limit=25&after=[FILTERED]"
}
}
But even asking for the access_token the attribute is not returned.
Some considerations:
Permissions that I'm requesting during the authentication:
"email,pages_manage_metadata,pages_read_engagement,pages_read_user_content,pages_manage_engagement,pages_messaging,pages_messaging_subscriptions"
And the account has "MODERATE" role.
Am I missing something?
Requested the API as the docs show.
Expected to get the access_token attribute.

Related

Facebook Graph API Comments not returning

I am trying to get the comments on ratings from the Facebook API.
First I request a list of ratings for a page I own:
https://graph.facebook.com/v3.0/me/ratings?fields=open_graph_story?access_token=[access_token]
Response:
{
"data": [
{
"open_graph_story": {
"message": "The best place in the world(s), and this is to reach that limit in the facebook review.",
"start_time": "2018-05-24T22:56:23+0000",
"type": "pages.rates",
"data": {
"rating": {
"value": 5,
"scale": 5
},
"review_text": "The best place in the world(s), and this is to reach that limit in the facebook review.",
"is_hidden": false,
"language": "en"
},
"id": "1805660589743235"
}
},
{
"open_graph_story": {
"message": "Very good, not excellent though. Does Facebook change the created time if I edit this?",
"start_time": "2018-04-12T20:25:26+0000",
"type": "pages.rates",
"data": {
"rating": {
"value": 3,
"scale": 5
},
"review_text": "Very good, not excellent though. Does Facebook change the created time if I edit this?",
"is_hidden": false,
"language": "en"
},
"id": "106674383523012"
}
}
],
"paging": {
"cursors": {
"before": "MTAwMDA4OTc5MzQ4Mjc3Ojc3MzQwNTI3NjIwMTQyNAZDZD",
"after": "MTAwMDI1NDEzNTE3NzgxOjc3MzQwNTI3NjIwMTQyNAZDZD"
}
}
}
(I removed some superfluous fields)
Then I use the id from the open_graph_story to get the comments for a rating:
https://graph.facebook.com/v3.0/106674383523012/comments?access_token=[access_token]
Response:
{
"data": [
],
"paging": {
"cursors": {
"before": "WTI5dGJXVnVkRjlqZAFhKemIzSTZANVFF5T1RNeU1UUTVPRGszTWpNMU9qRTFNalkwT0RZAeE1qZAz0ZD",
"after": "WTI5dGJXVnVkRjlqZAFhKemIzSTZANVFE0TlRBM09URXlOamN5T1RreU9qRTFNamN5TURJek56ST0ZD"
}
}
}
It returns no data even though I can see comments on the actual rating when I visit the Facebook page. Why are no comments returned?
(Just to make sure that I had the correct permissions, I selected all the permissions possible in the graph api explorer.)

Facebook Graph Api not returning all pages

My Facebook profile is set as admin for 3 pages. But when I call the following address on postman e see that it returns only one of the pages:
https://graph.facebook.com/v2.12/me/accounts?fields=access_token,name,id,perms
This is the response:
{
"data": [
{
"access_token": "xxx",
"name": "Test Page",
"id": "1234",
"perms": [
"ADMINISTER",
"EDIT_PROFILE",
"CREATE_CONTENT",
"MODERATE_CONTENT",
"CREATE_ADS",
"BASIC_ADMIN"
]
}
],
"paging": {
"cursors": {
"before": "xxx",
"after": "xxx"
}
}
}
And When I debug the token I used to make the call everything seems OK, image below:
What Am I missing that causes it not to return the 3 pages That I'm admin of?

Get comments from facebook ads (marketing)

After I make an ads for my post on facebook ads manager.
Facebook Ads Manager show me how many comment belong to this ads. This is very important for me to verify the effective of my campaign.
In programing aspect: Is there's any way to count number belong to my ads like Facebook Ads Manager (I describe above). I have used both Java Facebook Ads SDK (Ads Insight module from https://github.com/facebook/facebook-java-ads-sdk) and Graph Explorer Tool, they both return "comment" field or "like" field not existed
Please help!
You can't get comments nor reactions from Marketing Insights directly.
I stand corrected. If you have access to an ad_account insights, then you can use Marketing API to get a post's comments directly. Thanks #lamxung55
Let's say you have and ad_id of 123000000
If you have a token with ads_management or ads_read permission, you can make a request to the Marketing API such as
/123000000?fields=creative.fields(effective_object_story_id),insights.fields(actions)
This will give you the effective_object_story_id which is the object_id of the post ({page_id}_{post_id}), and its insights including its actions broken down by action type. For example:
{
"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"
}
}
}
}
The effective_object_story_id (so, post_id) is 456000000_789000000.
You can then query the comments edge of the post adding summary=true as a parameter. This endpoint is public for common posts (however, it won't work for non public posts)
/456000000_789000000/comments?summary=true
Which will respond with an object like
{
"data": [
<LOTS OF COMMENTS HERE>
],
"paging": {
<PAGING LINKS>
},
"summary": {
"order": "chronological",
"total_count": 50,
"can_comment": true
}
}
This means the post has had 50 comments, of which 12 were made through a paid action.
We can simply use this syntax to get adset comment: ...adset_id/insights?fields=actions. Another ads stuffs are the same

How to get picture of user who has commented on my facebook post?

I have post_id of the status which user share by iOS app, Now with graph api, I'm getting comment info and like info:
POST_ID?fields=likes.fields(pic_square,name),comments
With above, I'm able to fetch most of the details, but not profile pic of user who commented on post. check details which I'm getting:-
{
"id": "POST_ID",
"updated_time": "2014-03-25T07:07:14+0000",
"likes": {
"data": [
{
"pic_square": "https://fbcdn-profile-a.akamaihd.net/static- ak/rsrc.php/v2/yo/r/UlIqmHJn-SK.gif",
"name": "User name",
"id": "100007640XXXXX"
}
],
"paging": {
"cursors": {
"after": "MTAwMDA3NjQwMzcxMzQxxx",
"before": "MTAwMDA3NjQwMzcxMzQxxx"
}
}
},
"comments": {
"data": [
{
"id": "2069772628xxxxxx",
"from": {
"name": "user name",
"id": "100007640xxxxxx"
},
"message": "great reader..",
"can_remove": true,
"created_time": "2014-03-26T06:19:36+0000",
"like_count": 0,
"user_likes": false
}
],
"paging": {
"cursors": {
"after": "MQ==",
"before": "MQ=="
}
}
}
}
Now I need picture of a user who commented on post, I'm getting picture of user who likes, but not who commented. I tried to get it with FQL but not succeed.
Here in response you are getting user id who had liked your post so use that as follows
https://graph.facebook.com/10000445993xxxxx/picture?type=large
Use this API:
https://graph.facebook.com/100007640xxxxxx/picture
100007640xxxxxx: is userid.
Edit:
if you want to load user picture in particular size then you can use following:
https://graph.facebook.com/100007640xxxxxx/picture?width=150&height=150

Getting Likes count of each posts on a fan page in Facebook

How do I get the 'like' count of a post on Facebook?
I got a link graph.facebook.com/userid_postid that says says I can do this. But How do I find the user or page ID and the ID of the post?
For example, if take any post on the fan page:
http://www.facebook.com/TipsLearnings of site http://adityabajaj.com
If I make a post on the fan page above, and people like the post, how would I get the number of likes of that post? I want to have that number available to show on a separate website.
You can use FQL
SELECT like_info.like_count, share_info.share_count, comment_info.comment_count FROM stream WHERE post_id = 'your_post_id'
You can get a list of most recent posts a fan page made by using /<PAGE_ID>/posts (which you can find for your page by navigating to http://graph.facebook.com/myown.easytipsandtricks, or just use the username) with a valid access token. From that, you get an object that looks like this:
"data": [
{
"id": "22092443056_115909438544849",
"from": {
"name": "Starbucks",
"category": "Food/beverages",
"id": "22092443056"
},
// ...
"shares": {
"count": 708
},
"likes": {
"data": [
{
"name": "Shanna Gonzales",
"id": "100000244536406"
}
],
"count": 17129
},
"comments": {
"count": 759
}
}
// ... and more posts
Accessing the count subfield of each of those fields should tell you shares, likes and comments, respectively.
You can get the comments/likes count without having to paginate by using the fields parameter in combination with likes.limit(1).summary(true). For example, a search api query for pizza below will give you all public posts and their likes count summarized:
https://graph.facebook.com/search?q=pizza&type=post&fields=id,name,likes.limit(1).summary(true)
results (truncated):
{
"data": [
{
"id": "47883936273_659693910762305",
"name": "Instagram",
"created_time": "2014-02-16T01:15:29+0000",
"likes": {
"data": [
{
"id": "100002243084532",
"name": "Yvette Martin"
}
],
"paging": {
"cursors": {
"after": "MTAwMDAyMjQzMDg0NTMy",
"before": "MTAwMDAyMjQzMDg0NTMy"
},
"next": "https://graph.facebook.com/47883936273_659693910762305/likes?limit=1&summary=1&after=MTAwMDAyMjQzMDg0NTMy"
},
"summary": {
"total_count": 13682
}
}
},
{
"id": "136336876521150_314001148754721",
"name": "Pizza Box Turns into Plates & Storage Unit!",
"created_time": "2014-02-15T21:20:00+0000",
"likes": {
"data": [
{
"id": "100005373008864",
"name": "Liliana Campoli"
}
],
"paging": {
"cursors": {
"after": "MTAwMDA1MzczMDA4ODY0",
"before": "MTAwMDA1MzczMDA4ODY0"
},
"next": "https://graph.facebook.com/136336876521150_314001148754721/likes?limit=1&summary=1&after=MTAwMDA1MzczMDA4ODY0"
},
"summary": {
"total_count": 2792
}
}
}