Query Group Feed Posts by `created_time` - facebook-graph-api

For a small Facebook Sales Group Monitor I need to query the group's new posts. I've intended to do this via the Graph API, requesting only posts which have been either
created since the last query (created_time) or
updated since the last query (updated_time).
This, however, seems not to be possible.
Omitting all non-date fields, a GET /v2.7/<group-id>/feed request returns the following data:
"data": [
{
"updated_time": "2016-01-12T20:11:02+0000",
"created_time": "2014-09-16T09:55:39+0000",
"id": "552364968142715_789142084465001"
},
{
"updated_time": "1970-01-01T00:16:40+0000",
"created_time": "2016-08-28T19:15:53+0000",
"id": "552364968142715_1183108935068312"
},
{
"updated_time": "1970-01-01T00:16:39+0000",
"created_time": "2016-08-29T14:13:22+0000",
"id": "552364968142715_1183722648340274"
},
{
"updated_time": "1970-01-01T00:16:38+0000",
"created_time": "2016-08-28T09:15:05+0000",
"id": "552364968142715_1182673285111877"
},
...
]
The first entry is from the pinned group-rules post, created in 2014, updated 2016.
The second and fourth entries are both from yesterday, the third post is from today.
All but the first post have updated_time-timestamps close to the UNIX epoch's beginning. With a few exceptions, the value seems to be decreasing by 1 second for every post in the list, even when requesting 100+ posts.
The API Reference for Group feeds states, that the since=<timestamp> query parameter only applies on the updated_time field, which does not help in this case.
Is there any way to filter for or at least sort by the created_time value?

I am running into same problem. It seems currently created_time only apply for Page feed, not Group feed at the moment :(

Related

searchContacts with phone number query is broken

Using the [searchContacts API method] (https://developers.google.com/people/api/rest/v1/people/searchContacts) used to support searching by telephone number - indeed this is called out in the documentation:
The query matches on a contact's names, nickNames, emailAddresses, phoneNumbers, and organizations fields that are from the CONTACT source.
It no longer returns results when using a phone number as the query. Is this deliberate, or a bug?
As per google people api search by phonenumbers I have tried a query of "canonical format without plus". I have also tried "canonical format with plus" and "exact number as stored".
Name query still works
https://people.googleapis.com/v1/people:searchContacts?readMask=names%2cphoneNumbers&query=Go Ogle&pageSize=30
returns
{
"results": [
{
"person": {
"resourceName": "people/c832768086350305259",
"etag": "%EgcBAgsuNz0/GgECIgwxZGVYd20reHpEUT0=",
"names": [
{
"metadata": {
"primary": true,
"source": {
"type": "CONTACT",
"id": "b8e96298f3117eb"
}
},
"displayName": "Go Ogle",
"familyName": "Ogle",
"givenName": "Go",
"displayNameLastFirst": "Ogle, Go",
"unstructuredName": "Go Ogle"
}
],
"phoneNumbers": [
{
"metadata": {
"primary": true,
"source": {
"type": "CONTACT",
"id": "b8e96298f3117eb"
}
},
"value": "020 7031 3000",
"canonicalForm": "+442070313000"
}
]
}
}
]
}
Phone number query fails
https://people.googleapis.com/v1/people:searchContacts?readMask=names%2cphoneNumbers&query=442070313000&pageSize=30
returns
{}
The query function does indeed seem to be broken at the moment. My tests gave the same results and the question you linked shows that it clearly worked in the past.
I found a bug report on Google's issue tracker. A Googler already replied to it saying that they were able to reproduce it and filed an internal report. It's a matter of time until they fix it so you may want to keep track of that thread or post on it yourself to apply some pressure.
The bug didn't went away although they say it was closed and verified
In order to get the same functionality I had to be creative, the documentation says:
The query matches on a contact's names, nickNames, emailAddresses,
phoneNumbers, and organizations fields that are from the CONTACT
source.
The names, emailAddresses, phoneNumbers and organizations are important fields where you don't want to have garbage, but on my case at least the nickNames had no usage, so I simply add the phone number as nick name and the search works like charm.
Keep in mind that if you have many previous contacts you will have to write a script that will copy their phone number to the one of the nicknames fields.
Enjoy :)

how to get facebook page creation date using facebook api

my try : https://graph.facebook.com/v12.0/{mypageid}?fields={fieldname_of_type_PageStartDate}
Could not get any response when using this api and i am also confused about {fieldname_of_type_PageStartDate} parameter value. i tried day,month,year value according to https://developers.facebook.com/docs/graph-api/reference/page-start-date/ this fb website but it didn't work.
please suggest any way to get facenook page creation date using api.
The documentation is a bit misleading, because what that page does not tell you on its own, is that those fields are part of the start_info property of the page - so you have to query that one.
https://graph.facebook.com/v12.0/pageid?fields=start_info
This will give you a structure of the following format:
"data": [
{
"name": "...",
"start_info": {
"type": "Started",
"date": {
"year": 2021,
"month": 11,
"day": 29
}
},
"id": "1234567890"
},
Not all sub-fields will always be set; you might for example encounter types Founded with only a year set, or Unspecified with no date info at all.
Note that this is not the actual page creation date; but the "start date" of the entity represented by the page. So it must be explicitly set in the page settings, otherwise this field will be empty.

How to get Facebook posts for og_object or shared url?

Articles from the blogging website get published on multiple Facebook pages and I need to get the list of facebook post urls that contain specific article url.
It is possible to get og_object details by article url using this request:
https://graph.facebook.com/v2.5/?id=http://spoilednyc.com/2015/02/10/16-bucket-list-must-dos-real-new-yorkers&access_token=ACCESS_TOKEN
The result will be:
"og_object": {
"id": "794284920664423",
"description": "New York City has so much to offer beyond the attractions most known to tourists. Want to go off the beaten path, here are some suggestions for you.",
"title": "Beyond the Tourist Attractions: 16 Bucket List Must-Dos for 'Real' New Yorkers",
"type": "article",
"updated_time": "2016-02-19T11:21:26+0000",
"url": "http://spoilednyc.com/2015/02/10/16-bucket-list-must-dos-real-new-yorkers/"
},
"share": {
"comment_count": 0,
"share_count": 15247
},
"id": "http://spoilednyc.com/2015/02/10/16-bucket-list-must-dos-real-new-yorkers"
}
From this point I can find, for example, a list of comments using
https://graph.facebook.com/v2.5/794284920664423/comments/?access_token=Access_Token
Is there a way to get Facebook posts or post-ids by og_object id in a similar way?

Populating search results with meta data in Amazon CloudSearch

Unfortunately, Amazon CloudSearch does not support nested JSON, meaning that the below document structure is not valid.
[{
"type": "add",
"id": 1,
"fields": {
"company_name": "My Company",
"services": [
{
"id": 123,
"name": "Construction",
"logo": "logo1.png"
},
{
"id": 456,
"name": "Programming",
"logo": "logo2.png"
}
]
}
}]
Basically I cannot nest an array of objects under the services key. In this particular scenario, only the nested name field has to be searchable, so what I could do is the following:
[{
"type": "add",
"id": 1,
"fields": {
"company_name": "My Company",
"services": [ "Construction", "Programming" ]
}
}]
The above JSON is valid, and I can still search for the service names. However, now I have lost some meta data about my services that I need when displaying the search results. Is there any way in which I can add the meta data to the document in Amazon CloudSearch and have it returned with my search results, such that I can use it when displaying the results?
Or do I have to fetch this additional meta data from my database afterwards to populate the search results with the additional data required to display the results? This does not seem feasible because it complicates my code much more than if I could fetch this data straight from CloudSearch. This would also impact the performance of the search, even though I could use caching - but I kind of want to avoid that if possible, because I don't need it for anything else right now.
So my questions are:
Can I somehow add the meta data for services to the CloudSearch documents and have it returned with my search results?
If not, should I then extract this data from my data store upon receiving the search results from CloudSearch?
Do you have any other solutions or ideas? Are there any best practices with this?
Thank you in advance!

Getting number of page likes, post shares and website clicks

How can I get number of page likes, post shares and website clicks aggregated by ad group. Post comments and post likes are fetched through field 'inline_actions' - https://developers.facebook.com/docs/reference/ads-api/adreportstats#columns (/reportstats/date_preset=yesterday&data_columns=['adgroup_id','inline_actions']&actions_group_by=['action_type']). I need a way to fetch these report items using api, just like they are returned using https://www.facebook.com/ads/manage/reporting.php.
To get data per adgroup level you must include adgroup_id or adgroup_name in data_columns - as you're doing.
Comments, Likes and many other actions are returned in column actions
You can specify which actions types you're interested in by specifying filters:
filters=[
{
"field": "action_type",
"type": "in",
"value": [
"like",
"page_engagement",
"post_engagement",
"post_like",
"comment",
"games.plays",
"post",
"photo_view",
"link_click",
"receive_offer",
"checkin",
"mention",
"tab_view",
"vote",
"follow",
"gift_sale",
"video_play",
"video_view",
"offsite_conversion",
"offsite_conversion.checkout",
"offsite_conversion.registration",
"offsite_conversion.lead",
"offsite_conversion.key_page_view",
"offsite_conversion.add_to_cart",
"offsite_conversion.other",
"app_install",
"app_engagement",
"app_story",
"app_use",
"credit_spent",
"mobile_app_install",
"app_custom_event",
"app_custom_event.fb_mobile_activate_app",
"app_custom_event.fb_mobile_complete_registration",
"app_custom_event.fb_mobile_content_view",
"app_custom_event.fb_mobile_search",
"app_custom_event.fb_mobile_rate",
"app_custom_event.fb_mobile_tutorial_completion",
"app_custom_event.fb_mobile_add_to_cart",
"app_custom_event.fb_mobile_add_to_wishlist",
"app_custom_event.fb_mobile_initiated_checkout",
"app_custom_event.fb_mobile_add_payment_info",
"app_custom_event.fb_mobile_purchase",
"app_custom_event.fb_mobile_level_achieved",
"app_custom_event.fb_mobile_achievement_unlocked",
"app_custom_event.fb_mobile_spent_credits",
"app_custom_event.other",
"rsvp"
]
}
]
However that's optional IIRC, API should send you all non-zero actions by default.