Querying application stats with aggregate by - facebook

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/

Related

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

ElasticSearch Reindex API and painless script to access date field

I try to familiarize myself with the Reindexing API of ElasticSearch and the use of Painless scripts.
I have the following model:
"mappings": {
"customer": {
"properties": {
"firstName": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"lastName": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"dateOfBirth": {
"type": "date"
}
}
}
}
I would like to reindex all documents from test-v1 to test-v2 and apply a few transformations on them (for example extract the year part of dateOfBirth, convert a date value to a timestamp, etc) and save the result as a new field. But I got an issue when I tried to access it.
When I made the following call, I got an error:
POST /_reindex?pretty=true&human=true&wait_for_completion=true HTTP/1.1
Host: localhost:9200
Content-Type: application/json
{
"source": {
"index": "test-v1"
},
"dest": {
"index": "test-v2"
},
"script": {
"lang": "painless",
"inline": "ctx._source.yearOfBirth = ctx._source.dateOfBirth.getYear();"
}
}
And the response:
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"ctx._source.yearOfBirth = ctx._source.dateOfBirth.getYear();",
" ^---- HERE"
],
"script": "ctx._source.yearOfBirth = ctx._source.dateOfBirth.getYear();",
"lang": "painless"
}
],
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"ctx._source.yearOfBirth = ctx._source.dateOfBirth.getYear();",
" ^---- HERE"
],
"script": "ctx._source.yearOfBirth = ctx._source.dateOfBirth.getYear();",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Unable to find dynamic method [getYear] with [0] arguments for class [java.lang.String]."
}
},
"status": 500
}
According to this tutorial Date fields are exposed as ReadableDateTime so they support methods like getYear, and getDayOfWeek. and indeed, the Reference mentions those as supported methods.
Still, the response mentions [java.lang.String] as the type of the dateOfBirth property. I could just parse it to e.g. an OffsetDateTime, but I wonder why it is a string.
Anyone has a suggestion what I'm doing wrong?

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

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!

Magento 2 REST API - get product by slug, or get media in REST search

I have an ember app which I'm using as the front end. I need to fetch a product from the REST api but instead of using the SKU, I need to use the slug. So I access the following endpoint which works fine: http://*.com/index.php/rest/V1/products?searchCriteria[filter_groups][0][filters][0][field]=url_key&searchCriteria[filter_groups][0][filters][0][value]=daniels-icecream-slug
However, the result is obviously a product list as opposed to the product endpoint, so some of the data is omitted. Namely, the media_gallery_entries field. So is there anyways I can either return this data in the /products?searchCriteria endpoint or is there a way I can fetch /products/:slug instead of /products/:sku for the product endpoint?
you need to define conditionType as well with the API Call like following
V1/products/?searchCriteria[filterGroups][0][filters][0][field]=url_key&searchCriteria[filterGroups][0][filters][0][value]=%shirt%&searchCriteria[filterGroups][0][filters][0][condition_type]=like
Parameters :
searchCriteria[filterGroups][0][filters][0][field]=url_key
searchCriteria[filterGroups][0][filters][0][value]=%shirt%
searchCriteria[filterGroups][0][filters][0][condition_type]=like
Note: Make sure to prefix & suffix % in value as per your requirements.
I am using the same in my api Calls and it works
I'm using Magento v2.2, and when I do a search, each item has a image attribute (in the custom_attributes list) that mangento automatically adds to a product when up add an image to it:
{
"items": [{
"sku": "MH07-XS-Black",
"name": "Hero Hoodie-XS-Black",
"custom_attributes": [{
"attribute_code": "description",
"value": "<p>Gray and black color blocking sets you apart as the Hero Hoodie keeps you warm on the bus, campus or cold mean streets. Slanted outsize front pockets keep your style real . . . convenient.</p>\n<p>• Full-zip gray and black hoodie.<br />• Ribbed hem.<br />• Standard fit.<br />• Drawcord hood cinch.<br />• Water-resistant coating.</p>"
},
{
"attribute_code": "image",
"value": "/m/h/mh07-black_main.jpg"
},
{
"attribute_code": "small_image",
"value": "/m/h/mh07-black_main.jpg"
},
{
"attribute_code": "thumbnail",
"value": "/m/h/mh07-black_main.jpg"
},
{
"attribute_code": "color",
"value": "49"
},
{
"attribute_code": "minimal_price",
"value": "54.0000"
},
{
"attribute_code": "category_ids",
"value": [
"15"
]
},
{
"attribute_code": "options_container",
"value": "container2"
},
{
"attribute_code": "required_options",
"value": "0"
},
{
"attribute_code": "has_options",
"value": "0"
},
{
"attribute_code": "url_key",
"value": "hero-hoodie-xs-black"
},
{
"attribute_code": "msrp_display_actual_price_type",
"value": "0"
},
{
"attribute_code": "tax_class_id",
"value": "2"
},
{
"attribute_code": "size",
"value": "167"
}
]
}]
}

How to create google datastore composite indices via REST API?

I am trying to change the order of my results but I keep getting an error saying You need an index to execute this query.
In my console, I doesn't say that any indices exist, but I set most of the indexed options to true.
I know in Java, I can create indices that relate to multiple properties either ascending or descending, how do I do this with the REST API?
Following the REST API docs for Google Datastore, my entities are created like this:
{
"mode": "TRANSACTIONAL",
"transaction": "Eb2wksWfYDjkGkkABRmGMQ_vKGijwNwm-tbxAbUPRt8N2RaUCynjSbGT7jFQw3pgaDCT7U0drs3RTPLSIN8TQikdqkdl7pLm2rkMqORmKlO_I_dp",
"mutation": {
"insertAutoId": [
{
"key": {
"path": [
{
"kind": "Attendance"
}
]
},
"properties": {
"section": {
"indexed": true,
"stringValue": "Venturers"
},
"date": {
"dateTimeValue": "2015-01-16T00:00:00+00:00",
"indexed": true
},
"attendee": {
"indexed": true,
"keyValue": {
"path": [
{
"id": "5659313586569216",
"kind": "Attendee"
}
]
}
},
"presence": {
"indexed": false,
"integerValue": 0
}
}
}
]
}
}
And I am trying to query like this:
{
"gqlQuery": {
"allowLiteral": true,
"queryString": "SELECT * FROM Attendance WHERE section = #section ORDER BY date ASC",
"nameArgs": [
{
"name": "section",
"value": {
"stringValue": "Venturers"
}
}
]
}
}
And I get this error:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "FAILED_PRECONDITION",
"message": "no matching index found.",
"locationType": "header",
"location": "If-Match"
}
],
"code": 412,
"message": "no matching index found."
}
}
For future reference:
You can't make a composite index directly through the REST API. You must go through php app engine.
How to build datastore indexes (PHP GAE)