Retrieve impressions of a post that was made via my Facebook App - facebook

There is a way to get the impressions insights of a post throught the graph api? I use my app to publish photos in the users profiles with then permission but i dont get any impressions of that post just likes, comments, reactions... I use the metric parameters from the App Insights documentation but this is what i get in all the cases:
{
"data": [
{
"time": "2017-08-15T08:00:00+0000",
"value": "0"
},
{
"time": "2017-08-16T08:00:00+0000",
"value": "0"
},
{
"time": "2017-08-17T08:00:00+0000",
"value": "0"
},
{
"time": "2017-08-18T08:00:00+0000",
"value": "0"
},
{
"time": "2017-08-19T08:00:00+0000",
"value": "0"
},
{
"time": "2017-08-20T08:00:00+0000",
"value": "0"
},
{
"time": "2017-08-21T08:00:00+0000",
"value": "0"
}
]
}
I log in different test users accounts and see this specific post, create comments and put likes but there is no impressions... Can somebody help me with this problem? Thanks!

Related

Not getting filtered ads from facebook ads api

I am using facebook marketing api to retrieve fb ads.
Using facebook graph api explorer I am trying to retrieve list of ads on the basis of ad-sets
https://graph.facebook.com/v10.0/adset_id/ads?fields=name,configured_status&configured_status=["ACTIVE"]
but it showing me all the ads(Active,Paused) instead of filtering(active only).
Is there anything I am missing?
You should use the filtering params. Seems is not possible to filter for status or configured_status but you should use the effective_status instead.
...&filtering=[{ "field": "effective_status","operator": "IN","value": ["ACTIVE" ]}]
As example, for this adsets:
<adset-id>/ads?fields=id,status,effective_status
With the following data:
{
"data": [
{
"id": "<ad-id>",
"status": "ACTIVE",
"effective_status": "ACTIVE"
},
{
"id": "<ad-id>",
"status": "PAUSED",
"effective_status": "PAUSED"
},
{
"id": "<ad-id>",
"status": "PAUSED",
"effective_status": "PAUSED"
},
.....
}
You can apply the filtering like:
<adset-id>/ads?fields=id,status,effective_status&filtering=[{ "field": "effective_status","operator": "IN","value": ["ACTIVE" ]}]
Will return:
{
"data": [
{
"id": "<ad-id>",
"status": "ACTIVE",
"effective_status": "ACTIVE"
}
],
....
}

Why I do not receive the attachments in the Facebook Messenger webhook request?

Since yesterday (29/10/2020) i'm having this problem only on one of the pages linked to my app, the others work correctly:
The attached messages that the webhook receives from Facebook do not contain the attachment field.
Only messages with stickers contain the "attachment" field. All others (image, video, audio etc.) No.
What I expect (as facebook documentation) is:
{
"id": "682498302938465",
"time": 1518479195594,
"messaging": [
{
"sender": {
"id": "<PSID>"
},
"recipient": {
"id": "<PAGE_ID>"
},
"timestamp": 1518479195308,
"message": {
"mid": "mid.$cAAJdkrCd2ORnva8ErFhjGm0X_Q_c",
"attachments": [
{
"type": "<image|video|audio|file>",
"payload": {
"url": "<ATTACHMENT_URL>"
}
}
]
}
}
]
}
but I only receive:
{
"object": "page",
"entry": [
{
"id": "119320008135788",
"time": 1604051633128,
"messaging": [
{
"sender": {
"id": "XXXXXX"
},
"recipient": {
"id": "XXXXXX"
},
"timestamp": 1604051632953,
"message": {
"mid": "m_7DRP...."
}
}
]
}
]
}
This only happens on one page from 29/10/2020
Does anyone have the same problem / know why it happens?
The Facebook support team has confirmed my problem, and is investigating.
I am now solving using the graph api to get the desired message information using the mid
GET /v8.0/{message-id} HTTP/1.1
Host: graph.facebook.com
https://developers.facebook.com/docs/graph-api/reference/v8.0/message
Ex.
GET
https://graph.facebook.com/v8.0/' + mid + '?fields=message%2Cfrom%2Csticker%2Ctags%2Cid%2Cattachments.limit(10)%7Bid%2Cimage_data%2Cmime_type%2Cname%2Cfile_url%2Cvideo_data%7D&access_token=XXXXXX

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

Querying application stats with aggregate by

I am migrating code to v2.2 of the API and need to separate the clicks/impressions between unique and non unique.
The API docs ask us to pass count and uu as values for the aggregateBy modifier which if i pass uu it returns an error->
/v2.2/appid12345/app_insights/story_impressions?aggregateBy=uu
{
"error": {
"message": "(#100) Param aggregateBy must be one of {COUNT, USERS, TOPK, SUM, USD_SUM, UNKNOWN_USERS}",
"type": "OAuthException",
"code": 100
}
}
But if i pass USERS as the error message states i get json returned
/v2.2/appid12345/app_insights/story_impressions?aggregateBy=USERS
{
"data": [
{
"time": "2015-01-15T08:00:00+0000",
"value": "56"
},
{
"time": "2015-01-16T08:00:00+0000",
"value": "128"
},
{
"time": "2015-01-17T08:00:00+0000",
"value": "196"
},
{
"time": "2015-01-18T08:00:00+0000",
"value": "420"
},
{
"time": "2015-01-19T08:00:00+0000",
"value": "304"
},
{
"time": "2015-01-20T08:00:00+0000",
"value": "176"
},
{
"time": "2015-01-21T08:00:00+0000",
"value": "128"
}
]
}
My questions is- can i assume the USERS value with the modifier returns the unique count? and the COUNT values returns the non unique?
Its been reported to facebook as a bug
https://developers.facebook.com/bugs/412068288957160/

How to get count of each fan's likes, comments for posts on Facebook page using Graph API

I want to create app for get users' interaction with page. Each users like, comments, share specific page post.
I want to get count of total likes, comments and shares done by each user.
I used Graph API to return page
https://graph.facebook.com/PAGE_ID/feed?fields=id,likes,comments{from},shares
i got results similar to this.
{
"data": [
{
"id": "478412518924513_633895136709583",
"likes": {
"data": [
{
"id": "3696534343199936",
"name": "User Name"
},
{
"id": "576343349495810279",
"name": "User name"
}
],
},
"comments": {
"data": [
{
"from": {
"id": "154e3485900543",
"name": "user name"
},
"id": "633895096709587_633907896708307"
},
{
"from": {
"id": "10202701931494709",
"name": "User anme"
},
"id": "633895096709587_633899590042471"
}
],
}
},
How can i get how many likes,comments made by each user?
There are no endpoints you can get these counts from. This means that you have to aggregate the data yourself, namely
1) Iterating over the Page's Feed:
GET /{Page_ID}/feed?fields=id,created_time,likes{id},comments{from{id}},sharedposts&limit=200
and use the paging info to get the next results
See
https://developers.facebook.com/docs/graph-api/reference/v2.1/page/feed/#read
https://developers.facebook.com/docs/graph-api/reference/v2.1/post#edges
2) Aggregate the resulting data yourself in your application