Facebook Data Concern - facebook

i have concern about the data returned from facebook api for reach, below is the JSON data i am gonna post:
{
"id": "0123456789/insights/page_impressions_unique/day",
"name": "page_impressions_unique",
"period": "day",
"values": [
{
"value": 54,
"end_time": "2014-08-16T07:00:00+0000"
},
{
"value": 6,
"end_time": "2014-08-17T07:00:00+0000"
},
{
"value": 2,
"end_time": "2014-08-18T07:00:00+0000"
}
],
"title": "Daily Total Reach",
"description": "Daily: The number of people who have seen any content associated with your Page. (Unique Users)"
},
{
"id": "0123456789/insights/page_impressions_by_age_gender_unique/day",
"name": "page_impressions_by_age_gender_unique",
"period": "day",
"values": [
{
"value": {
"F.35-44": 20,
"M.35-44": 11,
"F.25-34": 10,
"M.25-34": 5,
"F.55-64": 4,
"F.45-54": 4,
"F.18-24": 2,
"M.13-17": 1,
"M.65+": 1,
"M.45-54": 1,
"M.18-24": 1
},
"end_time": "2014-08-16T07:00:00+0000"
},
{
"value": [
],
"end_time": "2014-08-17T07:00:00+0000"
},
{
"value": [
],
"end_time": "2014-08-18T07:00:00+0000"
}
],
"title": "Daily Reach Demographics",
"description": "Daily: Total Page Reach by age and gender. (Unique Users)"
}
looking above data i get concerned,
the data for 16th for unique page reach is 54, and in demographic detail data the reach becomes on summing 60 for 16th,
similarly data returned from facebook for 17th and 18th are totally different.
why is it so? what should i do to get the proper data?

Related

Increase Precision of Text Parsed via Facebook Duckling?

I'm using Facebook Duckling to parse some text but the results include some odd dimensions:
String text = "Tomorrow, February 28";
String result = Duckling.parseText(text);
Result:
[
{
"body": "Tomorrow, February 28",
"start": 0,
"value": {
"values": [
{
"value": "2022-02-28T00:00:00.000-08:00",
"grain": "day",
"type": "value"
}
],
"value": "2022-02-28T00:00:00.000-08:00",
"grain": "day",
"type": "value"
},
"end": 21,
"dim": "time",
"latent": false
},
{
"body": "28'",
"start": 19,
"value": {
"value": 28,
"type": "value",
"minute": 28,
"unit": "minute",
"normalized": {
"value": 1680,
"unit": "second"
}
},
"end": 22,
"dim": "duration",
"latent": false
},
{
"body": "28'",
"start": 19,
"value": {
"value": 28,
"type": "value",
"unit": "foot"
},
"end": 22,
"dim": "distance",
"latent": false
}
]
This result is odd since from the context of the query the text "28" is clearly referring to the day of month but Duckling also returns data as if it were referring to the Distance dimension.
Is there a way to make Duckling context aware and have it only return results matching the full query? Passing "dimensions" as argument is not ideal since I don't know the dimensions in advance.
Thanks

Subtotal is not calculated correctly at order preview

I want to create a chatbot with Dialogflow and Google Assistant along with Google Transactions API for enabling a user to order some items. For now my agent contains the following four intents:
Default Welcome Intent (text response: Hello, do you want to buy a chocolate box?)
Default Fallback Intent
Int3 (training phrase: Yes, I want, fulfilment: enabled webhook)
Int4 (event: actions_intent_TRANSACTION_DECISION, fulfilment: enabled webhook)
I am using Dialogflow Json instead of Node.js to connect my agent with Transactions API. I want to build a cart and an order for the user by using finally that the user meets the transaction requirements by using the actions.intent.TRANSACTION_DECISION action of Google actions. For this reason, following Google docs, when Int3 is triggered I am using a webhook which connect Google Assistant my back-end which sends back the following json (to trigger actions.intent.TRANSACTION_DECISION) :
{
"fulfillmentText": "This is your order preview:",
"payload": {
"google": {
"expectUserResponse": true,
"isSsml": false,
"noInputPrompts": [],
"systemIntent": {
"data": {
"#type": "type.googleapis.com/google.actions.v2.TransactionDecisionValueSpec",
"orderOptions": {
"requestDeliveryAddress": true
},
"paymentOptions": {
"actionProvidedOptions": {
"displayName": "VISA **** **** **** 3235",
"paymentType": "PAYMENT_CARD"
}
},
"proposedOrder": {
"cart": {
"lineItems": [
{
"description": "Book",
"id": "1",
"name": "Book",
"price": {
"amount": {
"currencyCode": "USD",
"nanos": 0,
"units": 31
},
"type": "ACTUAL"
},
"quantity": 2,
"subLines": [],
"type": "REGULAR"
}
],
"merchant": {
"id": "Amazon",
"name": "Amazon"
},
"otherItems": []
},
"id": "<UNIQUE_ORDER_ID>",
"otherItems": [
{
"id": "Subtotal",
"name": "Subtotal",
"price": {
"amount": {
"currencyCode": "USD",
"nanos": 0,
"units": 62
},
"type": "ACTUAL"
},
"type": "SUBTOTAL"
},
{
"id": "Delivery fees",
"name": "Delivery fees",
"price": {
"amount": {
"currencyCode": "USD",
"nanos": 0,
"units": 10
},
"type": "ACTUAL"
},
"type": "FEE"
}
],
"totalPrice": {
"amount": {
"currencyCode": "USD",
"units": 72
},
"type": "ACTUAL"
}
}
},
"intent": "actions.intent.TRANSACTION_DECISION"
}
}
}
}
However, I am getting the following errors on Google Assistant simulator:
MalformedResponse
expected_inputs[0].possible_intents[0].input_value_data.transaction_decision_value_spec.proposed_order: subtotal price is not sum of regular lineItems. Expected-> Sum of line item price: units: 31 nanos: 0 currency: USD Actual-> Provided total price: units: 62 nanos: 0 currency: USD.
MalformedResponse
expected_inputs[0].possible_intents[0].input_value_data.transaction_decision_value_spec.proposed_order: total price is not sum of lineItems and otherItems. Expected-> Sum of line item price: units: 42 nanos: 0 currency: USD Actual-> Provided total price: units: 72 nanos: 0 currency: USD.
Why I am getting this error since I have specified that "quantity": 2 in the respective lineItem?
It is very obvious that the subtotal should be units: 62 since I have ordered "quantity": 2 products of units: 31 price each...
The final order preview looks like this (this is borrowed from Google docs examples):
The answer seems to be in the error message: the API expects a each line item's price to be a sum of the total items in that line item instead of a quantity price (relevant error phrase: "Sum of line item price"). The corrected JSON should look something like this:
{
"fulfillmentText": "This is your order preview:",
"payload": {
"google": {
"expectUserResponse": true,
"isSsml": false,
"noInputPrompts": [],
"systemIntent": {
"data": {
"#type": "type.googleapis.com/google.actions.v2.TransactionDecisionValueSpec",
"orderOptions": {
"requestDeliveryAddress": true
},
"paymentOptions": {
"actionProvidedOptions": {
"displayName": "VISA **** **** **** 3235",
"paymentType": "PAYMENT_CARD"
}
},
"proposedOrder": {
"cart": {
"lineItems": [
{
"description": "Book",
"id": "1",
"name": "Book",
"price": {
"amount": {
"currencyCode": "USD",
"nanos": 0,
"units": 62
},
"type": "ACTUAL"
},
"quantity": 2,
"subLines": [],
"type": "REGULAR"
}
],
"merchant": {
"id": "Amazon",
"name": "Amazon"
},
"otherItems": []
},
"id": "<UNIQUE_ORDER_ID>",
"otherItems": [
{
"id": "Subtotal",
"name": "Subtotal",
"price": {
"amount": {
"currencyCode": "USD",
"nanos": 0,
"units": 62
},
"type": "ACTUAL"
},
"type": "SUBTOTAL"
},
{
"id": "Delivery fees",
"name": "Delivery fees",
"price": {
"amount": {
"currencyCode": "USD",
"nanos": 0,
"units": 10
},
"type": "ACTUAL"
},
"type": "FEE"
}
],
"totalPrice": {
"amount": {
"currencyCode": "USD",
"units": 72
},
"type": "ACTUAL"
}
}
},
"intent": "actions.intent.TRANSACTION_DECISION"
}
}
}
}

Facebook Graph API - getting individual wall posts of a day

I am using Graph Explorer and trying to fetch each individual wall post my friends sent to me on a specific day (my birthday).
My request is for the feed:
https://graph.facebook.com/100000015733365/feed?access_token=xyz&since=7+October+2015
response:
{
"data": [
{
"id": "<post_id_2>",
"from": {
"name": "<name2>",
"id": "<id2>"
},
"story": "<name2> and 69 others wrote on your timeline.",
"story_tags": {
"0": [
{
"id": "<id2>",
"name": "<name2>",
"type": "user",
"offset": 0,
"length": 8
}
],
"37": [
{
"id": "<my_id>",
"name": "<my_name>",
"type": "user",
"offset": 37,
"length": 8
}
],
"13": [
{
"id": "<id3>",
"name": "<name3>",
"type": "user",
"offset": 13,
"length": 9
},
{
"id": "<id4>",
"name": "<name4>",
"type": "user",
"offset": 13,
"length": 9
},
{
"id": "<id5>",
"name": "<name5>",
"type": "user",
"offset": 13,
"length": 9
}
]
},
"privacy": {
"value": "",
"description": "",
"friends": "",
"allow": "",
"deny": ""
},
"type": "status",
"status_type": "wall_post",
"created_time": "2015-10-07T20:43:07+0000",
"updated_time": "2015-10-07T20:43:07+0000",
"is_hidden": false,
"is_expired": false
}
It seems Facebook groups the posts by content, it's okay on my wall (in web browser) but how can I turn off this behavior through the API call?
I cannot find any setting related to this even after I read the API reference thoroughly.
I need these grouped posts one by one because I would like to process them in python, since I cannot achieve this with the graph explorer I think it's okay to not post python code right now.
An alternative would be to expand this 'story' into a list of individual posts but this is well hidden according to the documentation.
Any help is appreciated, thanks!

Getting post_impressions in facebook insights return empty

I'm trying to get post_impressions (and other types) but I'm stuck with no data in "data" fields. I'm not using PHP SDK or anything else. Just playing around with the explorer at:
https://developers.facebook.com/tools/explorer/
And I'm referencing types from:
https://developers.facebook.com/docs/graph-api/reference/v2.2/insights
This is what I got for page_storytellers (where 123456 is the id of my page)
{
"data": [
],
"paging": {
"previous": "https://graph.facebook.com/v2.2/123456/insights/page_storytellers/?pretty=0&suppress_http_code=1&since=1417005166&until=1417264366",
"next": "https://graph.facebook.com/v2.2/123456/insights/page_storytellers/?pretty=0&suppress_http_code=1&since=1417523566&until=1417782766"
}
}
And this is what I get for page_storytellers_by_story_type for the same period.
{
"data": [
{
"id": "123456/insights/page_storytellers_by_story_type/day",
"name": "page_storytellers_by_story_type",
"period": "day",
"values": [
{
"value": {
"fan": 16,
"other": 10,
"page post": 2,
"coupon": 0,
"mention": 0,
"question": 0,
"checkin": 0,
"user post": 0
},
"end_time": "2014-11-30T08:00:00+0000"
},
{
"value": {
"fan": 15,
"page post": 5,
"other": 5,
"checkin": 1,
"coupon": 0,
"mention": 0,
"question": 0,
"user post": 0
},
"end_time": "2014-12-01T08:00:00+0000"
},
{
"value": {
"other": 139,
"fan": 97,
"page post": 33,
"user post": 2,
"coupon": 0,
"mention": 0,
"question": 0,
"checkin": 0
},
"end_time": "2014-12-02T08:00:00+0000"
}
],
"title": "Daily Talking About This by story type",
"description": "Daily: The number of people talking about your Page, by story type. (Unique Users)"
},
{
"id": "123456/insights/page_storytellers_by_story_type/week",
"name": "page_storytellers_by_story_type",
"period": "week",
"values": [
{
"value": {
"other": 206,
"fan": 116,
"page post": 90,
"user post": 4,
"checkin": 3,
"coupon": 0,
"mention": 0,
"question": 0
},
"end_time": "2014-11-30T08:00:00+0000"
},
{
"value": {
"other": 203,
"fan": 119,
"page post": 87,
"checkin": 4,
"user post": 4,
"coupon": 0,
"mention": 0,
"question": 0
},
"end_time": "2014-12-01T08:00:00+0000"
},
{
"value": {
"other": 310,
"fan": 210,
"page post": 103,
"user post": 5,
"checkin": 4,
"coupon": 0,
"mention": 0,
"question": 0
},
"end_time": "2014-12-02T08:00:00+0000"
}
],
"title": "Weekly Talking About This by story type",
"description": "Weekly: The number of people talking about your Page, by story type. (Unique Users)"
},
{
"id": "123456/insights/page_storytellers_by_story_type/days_28",
"name": "page_storytellers_by_story_type",
"period": "days_28",
"values": [
{
"value": {
"fan": 494,
"page post": 440,
"user post": 12,
"other": 9,
"checkin": 7
},
"end_time": "2014-11-30T08:00:00+0000"
},
{
"value": {
"fan": 500,
"page post": 438,
"user post": 11,
"other": 9,
"checkin": 7
},
"end_time": "2014-12-01T08:00:00+0000"
},
{
"value": {
"fan": 588,
"page post": 510,
"user post": 12,
"other": 9,
"checkin": 7
},
"end_time": "2014-12-02T08:00:00+0000"
}
],
"title": "28 Days Talking About This by story type",
"description": "28 Days: The number of people talking about your Page, by story type. (Unique Users)"
}
],
"paging": {
"previous": "https://graph.facebook.com/v2.2/123456/insights/page_storytellers_by_story_type/?pretty=0&suppress_http_code=1&since=1417005354&until=1417264554",
"next": "https://graph.facebook.com/v2.2/123456/insights/page_storytellers_by_story_type/?pretty=0&suppress_http_code=1&since=1417523754&until=1417782954"
}
}
Actually, from the facebook reference page, all types that have * don't work.
I have access token with manage_pages,read_insights and read_stream permissions. Any ideas?
First of all, you should use version 2.5 of the API if possible.
In your first request, you are trying to get "page_storytellers" from a page, which as of 2014-07-02 is deprecated.
See https://developers.facebook.com/bugs/273943399479102
Your title states that you need "post_impressions", which needs to be fetched from the post itself:
https://graph.facebook.com/v2.2/postid/insights/post_impressions_unique?access_token=x
See the documentation here: https://developers.facebook.com/docs/graph-api/reference/v2.5/insights

get my status from facebook api

I want to get my statues from facebook api.
for example:
I post a status on my facebook page:
I love apple.
I need to fetch the data.
I used facebook api.
FB.api('/me/feed', function(response)
{
//do my process
}
however, the data I get is in this format
data": [
{
"id": "*",
"from": {
"name": "*",
"id": "*"
},
"story": "* is now friends with \u674e\u7490 and \u9ec4\u68ee\u6d2a.",
"story_tags": {
"0": [
{
"id": "*",
"name": "****",
"offset": 0,
"length": 9,
"type": "user"
}
],
"30": [
{
"id": "100003483506950",
"name": "\u674e\u7490",
"offset": 30,
"length": 2,
"type": "user"
}
],
"37": [
{
"id": "100008056628095",
"name": "\u9ec4\u68ee\u6d2a",
"offset": 37,
"length": 3,
"type": "user"
}
]
},
"privacy": {
"value": ""
},
"type": "status",
"status_type": "approved_friend",
"created_time": "2014-03-23T02:10:33+0000",
"updated_time": "2014-03-23T02:10:33+0000"
},
the things are all about friends approvment, but what I want is my status.
How should I get these information?
Thank you very much.
Chao
The edge {user_id}/feed will return everything that user has done. You can filter down the information returned by adding fields to select what data you want returned.
me/feed?fields=status_type
The status_type argument will return you which type of update it was and you can use that to filter out the updates you don't want.
You can also play around with the arguments at https://developers.facebook.com/tools/explorer/