facebook ads stats connections - facebook

Below is an example response i am getting for stats on an adgroup.
The "connections" returns 12 and the "actions" : null
How do i get to the break down of the connection? (pagelike/app installs/event responses)
Thank you!
{
"id": "XXXXX",
"impressions": "789862",
"clicks": "292",
"spent": "3019",
"social_impressions": "109327",
"social_clicks": "26",
"social_spent": "235",
"unique_impressions": 295055,
"social_unique_impressions": 18819,
"unique_clicks": 287,
"social_unique_clicks": 25,
"actions": null,
"connections": 12,
"adgroup_id": XXX,
"campaign_id": XXX,
"start_time": "2011-08-21T00:00:00+0000",
"end_time": "2011-08-22T00:00:00+0000",
"newsfeed_position": null
}

Check out the Ad Statistics and Conversion Statistics documentation - you're probably looking for /conversions instead of /stats
Sample query: /<CAMPAIGN ID>/conversions/0/1354207892
sample response is:
{
"campaign_id": <CAMPAIGN ID>,
"values": [
{
"start_time": 0,
"end_time": 1354233600,
"conversions": [
{
"action_type": "like",
"object_id": <PAGE ID>,
"post_click_1d": 345,
"post_click_7d": 349,
"post_click_28d": 351,
"post_imp_1d": 53,
"post_imp_7d": 89,
"post_imp_28d": 104
},
{
"action_type": "link_click",
"object_id": <PAGE ID>,
"post_click_1d": 893,
"post_click_7d": 904,
"post_click_28d": 938,
"post_imp_1d": 120,
"post_imp_7d": 185,
"post_imp_28d": 235
},
]
}
]

In my experience, you will get a non-null result for the actions field of a stats query if you don't specify a start_time.

Related

How to exclude some item when query with typeorm in Nestjs and Postgres

I want to build a query when i send username to server so i can exclude the record has the excludeUsers has the same username i sent.
Here is my data : `
"id": "f4830220-9912-4cbb-b685-edf4aaaf8fd5",
"createdAt": "2022-03-24T10:19:48.096Z",
"updatedAt": "2022-03-24T10:26:42.487Z",
"isDeleted": false,
"username": "vietphuongthoa98",
"link": "",
"type": "follow",
"current": 13456,
"target": 13556,
"totalPurchase": 100,
"purchasedPacks": [
{
"id": "fbb3079b-32c9-4c4b-a297-16741d1f5485",
"name": "Some packets",
"type": "follow",
"count": 2,
"price": 100,
"follows": 50,
"createdAt": "2022-03-23T07:18:22.898Z",
"isDeleted": false,
"updatedAt": "2022-03-23T09:49:30.192Z",
"description": "Some packages description.",
"originPrice": 0
}
],
"excludeUsers": [
{
"id": "9d8c25d2-8f03-46b3-92fa-b9489b943a56",
"deviceName": "iPhone 12 Pro Max",
"username": "hoaa.hanassii",
"platform": "ios",
"timeZone": 0,
"deviceAge": 21,
"subscribed": true,
"coins": 19600,
"subscriptionExpiration": "2022-04-27T00:00:00.000Z",
"isBlocked": false
}
]
Here is my query builder :
queryBuilder
.leftJoin('featured_user.excludeUsers', 'excludeUsers')
.andWhere('excludeUsers.username != :username', {
username: filter.username,
});
The actual query result is :
SELECT "featured_user"."id" AS "featured_user_id",
"featured_user"."tenant_id" AS "featured_user_tenant_id",
"featured_user"."created_at" AS "featured_user_created_at",
"featured_user"."updated_at" AS "featured_user_updated_at",
"featured_user"."is_deleted" AS "featured_user_is_deleted",
"featured_user"."username" AS "featured_user_username",
"featured_user"."link" AS "featured_user_link",
"featured_user"."type" AS "featured_user_type",
"featured_user"."current" AS "featured_user_current",
"featured_user"."target" AS "featured_user_target",
"featured_user"."total_purchase" AS "featured_user_total_purchase",
"featured_user"."purchased_packs" AS "featured_user_purchased_packs",
"featured_user"."user_id" AS "featured_user_user_id",
"excludeUsers"."username" AS "excludeUsers_username",
"excludeUsers"."id" AS "excludeUsers_id"
FROM "featured_users" "featured_user"
LEFT JOIN "featured_users_exclude_users_users" "featured_user_excludeUsers" ON "featured_user_excludeUsers"."featured_users_id"="featured_user"."id"
LEFT JOIN "users" "excludeUsers" ON "excludeUsers"."id"="featured_user_excludeUsers"."users_id"
WHERE "excludeUsers"."username" != $1 -- PARAMETERS: ["hoaa.hanassii"]
The problem is nothing response. Any ideal ? Thanks
can you add getMany() end of querybuilder and try
queryBuilder
.leftJoin('featured_user.excludeUsers', 'excludeUsers')
.andWhere('excludeUsers.username != :username', {
username: filter.username,
}).getMany()

Check if student submitted assignment via Moodle web services

I am trying to use the Moodle API (web services) to get information about (my) assignment submissions. I want to know whether I submitted an attempt for the assignment already or not. I am using the mod_assign_get_assignments function (which doesn't have too much documentation) and the results I get (when looking at the assignments portion of each course) are:
{
"id": 25960,
"cmid": 350053,
"course": 8013502,
"name": "\u05d4\u05d2\u05e9\u05ea \u05ea\u05e8\u05d2\u05d9\u05dc \u05d1\u05d9\u05ea 1",
"nosubmissions": 0,
"submissiondrafts": 0,
"sendnotifications": 0,
"sendlatenotifications": 0,
"sendstudentnotifications": 0,
"duedate": 1617566400,
"allowsubmissionsfromdate": 0,
"grade": 100,
"timemodified": 1615897679,
"completionsubmit": 1,
"cutoffdate": 1617569940,
"gradingduedate": 0,
"teamsubmission": 0,
"requireallteammemberssubmit": 0,
"teamsubmissiongroupingid": 0,
"blindmarking": 0,
"hidegrader": 0,
"revealidentities": 0,
"attemptreopenmethod": "manual",
"maxattempts": 1,
"markingworkflow": 0,
"markingallocation": 0,
"requiresubmissionstatement": 0,
"preventsubmissionnotingroup": 0
...irrelevant configuations
}
The above result is for an assignment I have already submitted.
An example of an assignment I did not submit is:
{
"id": 19764,
"cmid": 268225,
"course": 8013201,
"name": "\u05ea\u05d9\u05d1\u05ea \u05d4\u05d2\u05e9\u05d4 14",
"nosubmissions": 0,
"submissiondrafts": 0,
"sendnotifications": 0,
"sendlatenotifications": 0,
"sendstudentnotifications": 0,
"duedate": 1611693000,
"allowsubmissionsfromdate": 0,
"grade": 100,
"timemodified": 1610972842,
"completionsubmit": 0,
"cutoffdate": 1611694860,
"gradingduedate": 0,
"teamsubmission": 0,
"requireallteammemberssubmit": 0,
"teamsubmissiongroupingid": 0,
"blindmarking": 0,
"hidegrader": 0,
"revealidentities": 0,
"attemptreopenmethod": "manual",
"maxattempts": 1,
"markingworkflow": 0,
"markingallocation": 0,
"requiresubmissionstatement": 0,
"preventsubmissionnotingroup": 0
...irrelevant configuations
}
The only apparent difference between these (that might point to a way to check if I submitted it or not) is the completionsubmit property, but that cannot be the solution because a different assignment that I have submitted has it set to 0 (just like the one I didn't submit).
Does someone have an idea how I can solve this issue?
Thanks in Advance!
EDIT: mod_assign_get_submissions denies my access
{"assignments":[],"warnings":[{"item":"assignment","itemid":myitemname,"warningcode":"1","message":"No access rights in module context"}]}
I looked now into mod_assign_get_submission_status but it seems like it is only able to parse one assignment at a time, does anyone have a way to make this more efficient?
You could try using mod_assign_get_submissions instead to retrieve submissions to assignments. Available since Moodle 2.5
References
Moodle API
Emulated Data For Get Submissions from Moodle
Sample Response
{
"assignments": [
{
"assignmentid": 14,
"submissions": [
{
"id": 7,
"userid": 3,
"attemptnumber": 0,
"timecreated": 1426865031,
"timemodified": 1426865062,
"status": "submitted",
"groupid": 0,
"plugins": [
{
"type": "onlinetext",
"name": "Online text",
"fileareas": [
{
"area": "submissions_onlinetext"
}
],
"editorfields": [
{
"name": "onlinetext",
"description": "Submission comments",
"text": "<p>But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. <br></p>",
"format": 1
}
]
},
{
"type": "file",
"name": "File submissions",
"fileareas": [
{
"area": "submission_files",
"files": [
{
"filepath": "APDFfile.pdf",
"fileurl": "http://localhost/m/stable_master/webservice/pluginfile.php/247/assignsubmission_file/submission_files/12/somefile.pdf"
},
{
"filepath": "anotherfile.docx",
"fileurl": "http://localhost/m/stable_master/webservice/pluginfile.php/247/assignsubmission_file/submission_files/12/somefile.pdf"
}
]
}
]
},
{
"type": "comments",
"name": "Submission comments"
}
]
},
{
"id": 5,
"userid": 4,
"attemptnumber": 0,
"timecreated": 1426864693,
"timemodified": 1426864740,
"status": "draft",
"groupid": 0,
"plugins": [
{
"type": "onlinetext",
"name": "Online text",
"fileareas": [
{
"area": "submissions_onlinetext",
"files": [
{
"filepath": "/Arte esquemático-Cigüeña.png",
"fileurl": "http://localhost/m/stable_master/webservice/pluginfile.php/245/assignsubmission_onlinetext/submissions_onlinetext/5/Arte%20esquem%C3%A1tico-Cig%C3%BCe%C3%B1a.png"
}
]
}
],
"editorfields": [
{
"name": "onlinetext",
"description": "Submission comments",
"text": "<p>Blah Blah Blah lorem ipsum</p><p><br></p><p><b>Blah Blah Blah lorem ipsum</b><br></p><p><b><br></b></p><p><b><span style=\"font-weight: normal;\"><i>Blah Blah Blah lorem ipsum</i></span><br></b></p><p><b><span style=\"font-weight: normal;\"><i><br></i></span></b></p><p><b><span style=\"font-weight: normal;\"><i><img src=\"##PLUGINFILE##/Arte%20esquem%C3%A1tico-Cig%C3%BCe%C3%B1a.png\" alt=\"\" width=\"734\" height=\"844\" role=\"presentation\" style=\"vertical-align:text-bottom; margin: 0 .5em;\" class=\"img-responsive\"><br></i></span></b></p>",
"format": 1
}
]
},
{
"type": "file",
"name": "File submissions",
"fileareas": [
{
"area": "submission_files",
"files": [
{
"filepath": "somefile.pdf",
"fileurl": "http://localhost/m/stable_master/webservice/pluginfile.php/247/assignsubmission_file/submission_files/12/somefile.pdf"
}
]
}
]
},
{
"type": "comments",
"name": "Submission comments"
}
]
}
]
}
],
"warnings": []
}

Azure OCR difference between demo page and console

I have several examples of images I need to recognize with OCR.
I've tried to recognize them on the demo page https://azure.microsoft.com/en-us/services/cognitive-services/computer-vision/ and it works quite well. I use the "Read text in images" option, which works even better than "Read handwritten text from images".
But when I try to use the REST call from a script (according to the example given in documentation) results are much worse. Some letters are recognized wrong, some are totally missed. If I try running the same example from the development console https://westcentralus.dev.cognitive.microsoft.com/docs/services/5adf991815e1060e6355ad44/operations/56f91f2e778daf14a499e1fc/console I still get the same bad results.
What can cause this difference? How can I fix it to get reliable results as the demo page produces?
Maybe any additional information is required?
UPD: since I couldn't find any solution or even explanation of the difference I've created a sample file (similar to actual files) so you can have a look. The file url is http://sfiles.herokuapp.com/sample.png
You can see, if it is used on the demo page https://azure.microsoft.com/en-us/services/cognitive-services/computer-vision/ in section "Read text in images" the resulting JSON is
{
"status": "Succeeded",
"succeeded": true,
"failed": false,
"finished": true,
"recognitionResult": {
"lines": [
{
"boundingBox": [
307,
159,
385,
158,
386,
173,
308,
174
],
"text": "October 2011",
"words": [
{
"boundingBox": [
308,
160,
357,
160,
357,
174,
308,
175
],
"text": "October"
},
{
"boundingBox": [
357,
160,
387,
159,
387,
174,
357,
174
],
"text": "2011"
}
]
},
{
"boundingBox": [
426,
157,
519,
158,
519,
173,
425,
172
],
"text": "07UC14PII0244",
"words": [
{
"boundingBox": [
426,
160,
520,
159,
520,
174,
426,
174
],
"text": "07UC14PII0244"
}
]
}
]
}
}
If I use this file in the console and make the following call:
POST https://westcentralus.api.cognitive.microsoft.com/vision/v2.0/ocr?language=unk&detectOrientation =true HTTP/1.1
Host: westcentralus.api.cognitive.microsoft.com
Content-Type: application/json
Ocp-Apim-Subscription-Key: ••••••••••••••••••••••••••••••••
{"url":"http://sfiles.herokuapp.com/sample.png"}
I get different result:
{
"language": "el",
"textAngle": 0.0,
"orientation": "Up",
"regions": [{
"boundingBox": "309,161,75,10",
"lines": [{
"boundingBox": "309,161,75,10",
"words": [{
"boundingBox": "309,161,46,10",
"text": "October"
}, {
"boundingBox": "358,162,26,9",
"text": "2011"
}]
}]
}, {
"boundingBox": "428,161,92,10",
"lines": [{
"boundingBox": "428,161,92,10",
"words": [{
"boundingBox": "428,161,92,10",
"text": "071_lC14P110244"
}]
}]
}]
}
As you see the result is totally different (even the JSON format). Does anyone know what am I doing wrong, or maybe I'm missing something, and the "Read text in images" demo does not match the ocr method of the API?
Will be very grateful for any help.
There are two flavors of OCR in Microsoft Cognitive Services. The newer endpoint (/recognizeText) has better recognition capabilities, but currently only supports English. The older endpoint (/ocr) has broader language coverage.
Some additional details about the differences are in this post.

Better way to display images in Magento's default API response?

I am using Magento2 default API: /V1/carts/mine/payment-information.
The response from this API is:
{
"payment_methods": [
{
"code": "payu",
"title": "PayUMoney"
},
{
"code": "checkmo",
"title": "Check / Money order"
},
{
"code": "paytm",
"title": "Paytm PG"
}
],
"totals": {
"grand_total": 195,
"base_grand_total": 195,
"subtotal": 45,
"base_subtotal": 45,
"discount_amount": 0,
"base_discount_amount": 0,
"subtotal_with_discount": 45,
"base_subtotal_with_discount": 45,
"shipping_amount": 150,
"base_shipping_amount": 150,
"shipping_discount_amount": 0,
"base_shipping_discount_amount": 0,
"tax_amount": 0,
"base_tax_amount": 0,
"weee_tax_applied_amount": null,
"shipping_tax_amount": 0,
"base_shipping_tax_amount": 0,
"subtotal_incl_tax": 45,
"shipping_incl_tax": 150,
"base_shipping_incl_tax": 150,
"base_currency_code": "INR",
"quote_currency_code": "INR",
"items_qty": 1,
"items": [
{
"item_id": 41,
"price": 45,
"base_price": 45,
"qty": 1,
"row_total": 45,
"base_row_total": 45,
"row_total_with_discount": 0,
"tax_amount": 0,
"base_tax_amount": 0,
"tax_percent": 0,
"discount_amount": 0,
"base_discount_amount": 0,
"discount_percent": 0,
"price_incl_tax": 45,
"base_price_incl_tax": 45,
"row_total_incl_tax": 45,
"base_row_total_incl_tax": 45,
"options": "[{\"value\":\"Green\",\"label\":\"Color\"},{\"value\":\"29\",\"label\":\"Size\"}]",
"weee_tax_applied_amount": null,
"weee_tax_applied": null,
"name": "Erika Running Short"
}
],
"total_segments": [
{
"code": "subtotal",
"title": "Subtotal",
"value": 45
},
{
"code": "shipping",
"title": "Shipping & Handling (Fixed)",
"value": 150
},
{
"code": "tax",
"title": "Tax",
"value": 0,
"extension_attributes": {
"tax_grandtotal_details": []
}
},
{
"code": "grand_total",
"title": "Grand Total",
"value": 195,
"area": "footer"
}
]
}
}
I want to add the images tag inside items to display images of the items/products. But this tag is not defined in the interface of items, i.e
TotalsItemInterface.php
I replicated TotalsItemInterface in my custom module and added all getters and setters from Totalsinterface along with setImages and getImages Tag. Thus internally I call the method to use and show it by my custom apiInterfaces.
Is there a better or a proper "Magento 2 way" if we want to change the data displayed in the APIs?
You may use extension attributes for it. You can find more information about them in the devdocs there:
https://devdocs.magento.com/guides/v2.3/extension-dev-guide/extension_attributes/adding-attributes.html

How to search historic information from IBM Bluemix Weather Almanac API

I need to receive some information from Weather Company Data For IBM Bluemix APIs about a specific period (from jan 2012 to jan 2015).
The documentation includes this example API:
https://twcservice.mybluemix.net:443/api/weather/v1/geocode/33.40/-83.42/almanac/daily.json?units=e&start=0112&end=0115
But this is the result:
{"metadata":{"transaction_id":"1472145329818:-319071226","status_code":400},"success":false,"errors":[{"error":{"code":"PVE-0003","message":"The field 'start' contains a value '112' which is outside the expected range of [1 to 12]."}}]}
Can you let me know how I can search the historic information?
Thank you
https://twcservice.eu-gb.mybluemix.net/api/weather/v1/geocode/33.40/-83.42/almanac/daily.json?start=0112&end=0115&units=e
It works for me!!
{
"metadata": {
"language": "en-US",
"transaction_id": "1501849033676:-1423101749",
"version": "1",
"latitude": 33.4,
"longitude": -83.42,
"units": "e",
"expire_time_gmt": 1501869684,
"status_code": 200
},
"almanac_summaries": [
{
"class": "almanac",
"station_id": "095988",
"station_name": "MONTICELLO",
"almanac_dt": "0112",
"interval": "D",
"avg_hi": 56,
"avg_lo": 28,
"record_hi": 75,
"record_hi_yr": 1916,
"record_lo": 0,
"record_lo_yr": 1982,
"mean_temp": 42,
"avg_precip": 0.13,
"avg_snow": 0.1,
"record_period": 30
},
{
"class": "almanac",
"station_id": "095988",
"station_name": "MONTICELLO",
"almanac_dt": "0113",
"interval": "D",
"avg_hi": 56,
"avg_lo": 28,
"record_hi": 77,
"record_hi_yr": 1911,
"record_lo": 8,
"record_lo_yr": 1918,
"mean_temp": 42,
"avg_precip": 0.12,
"avg_snow": 0,
"record_period": 30
},
{
"class": "almanac",
"station_id": "095988",
"station_name": "MONTICELLO",
"almanac_dt": "0114",
"interval": "D",
"avg_hi": 56,
"avg_lo": 28,
"record_hi": 78,
"record_hi_yr": 1937,
"record_lo": 10,
"record_lo_yr": 1918,
"mean_temp": 42,
"avg_precip": 0.13,
"avg_snow": 0,
"record_period": 30
},
{
"class": "almanac",
"station_id": "095988",
"station_name": "MONTICELLO",
"almanac_dt": "0115",
"interval": "D",
"avg_hi": 56,
"avg_lo": 28,
"record_hi": 80,
"record_hi_yr": 1932,
"record_lo": 11,
"record_lo_yr": 1964,
"mean_temp": 42,
"avg_precip": 0.12,
"avg_snow": 0,
"record_period": 30
}
]
}