How to provide updateMask during Google People update contact? - google-people-api

If I need to update the name or address of a contact, giving the field as "names, addresses" works.
How do I need to give the updateMask to update a specific field like "middleName" alone.
Providing updateMask as "names.middleName" does not work and throws the following error:
{
"error": {
"code": 400,
"message": "Invalid updatePersonFields mask path: \"names.middle_name\". Valid paths are documented at https://developers.google.com/people/api/rest/v1/people/updateContact.",
"status": "INVALID_ARGUMENT"
}
}
Anyone help?

Answer:
You need to use names as updatePersonFields, but all names need to be specified. This may be a bug, as linked below, but it is also not clear from the documentation.
More Information:
It is possible this is a bug, though until a response is obtained from the issue tracker report (which I assume was you -but if not - hit the star to help it gain more attention) about this it is not possible to know for sure.
While FieldMasks do accept sub-fields, these are not specified on the updatePersonFields documentation page, only the broader names.
You can see the list of definitely supported fields here under the Query Parameters.
Current Workaround:
While waiting for Google to respond to the bug report, the only way you can get around this is by using the names field mask, but also including the firstName and lastName parameters too when making the patch:
{
"names": [
{
"givenName": "Rafa",
"middleName": "Guillermo",
"familyName": "Rocks"
}
],
"etag": "%XxXXXx00XxxXXXXXXxXXXX00XXXXXXxXxxX0"
}
Remember: If you leave out any of these fields this is tantamount to replacing it with empty string - so be careful!

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 :)

Facebook-marketing api - need access to type of creative format

I have a requirement in which I need to access the creative format type for each adCreative.
I explored the API and figured that this information is stored in Ad Creative Object Story Spec, however, I am not able to query this object.
This is the request I am making
https://graph.facebook.com/v2.11/<account_id>/adcreatives?fields=id,adset_id,name,creative,image_crops,object_story_id,image_url,image_hash,object_type,object_id,object__story_id,object_url&limit=500&access_token=<access_token>
This is not returning object_story_id and object_story_spec field only.
What am I missing here?
Thanks in advance.
Request those fields on the adcreative edge itself. ie your first call will return a list of adcreative ids.
{
"data": [
{
"id": "23842732907210427"
},
{
"id": "23842732907020427"
}]}
So you would call graph.facebook.com/23842732907210427?fields=object_story_id&access_token=USERACCESSTOKEN to retrieve the spec for that ad creative.
You can also nest queries so you may be able to retrieve the spec in a single call but I have been unsuccessful attempting this. https://developers.facebook.com/docs/graph-api/using-graph-api

Facebook Graph Api Get tagged comments

I am trying to gather information about the number of comments from a facebook past that include a tag to a user, i.e. when you type #Joe Bloggs.
I know you can get all comments by either getting using the Comments edge for a post v2.8/[Postid]/comments or by the comment id directly v2.8/[comment-id]
But the message field that is returned is plain text and includes no indication of tags. e.g. something like:
{
"created_time": "2017-02-28T09:31:08+0000",
"from": {
"name": "Fred Bloggs",
"id": "123"
},
"message": "Joe Bloggs look at this",
"id": "1234"
}
Is it possible to get this somehow?
You need to include the field message_tags in your request. It will give you an array of profiles tagged in this comment.

Did the city search data from the Facebook Ads API suddenly change?

The City Search call used to return a response where each city had the form:
{
"name": "Dublin, CA",
"key": 220522764,
"subtext": "CA, United States"
}
Now the API returns:
{
"name": "Dublin",
"key": 220522764,
"subtext": "California, United States"
}
The first format is still listed in the API docs here: https://developers.facebook.com/docs/reference/ads-api/get-autocomplete-data/
Is this a permanent change?
Our apologies for this change - we've reverted this change and will take precaution to avoid these things in the future. Thank you for the report.
We've added another parameter to use in your query if you want to get the city name without the state. Documentation updated: https://developers.facebook.com/docs/reference/ads-api/get-autocomplete-data/
Yes, last week. No warning from Facebook.

Understanding id returned by Facebook search

If in a web browser I enter:
https://graph.facebook.com/search?q=watermelon
the data returned begins:
{
"data": [
{
"id": "100000079215099_345415575486050",
"from": {
"name": "Synthia Stephen",
"id": "100000079215099"
},
My question relates to the id field. The value returned contains two numbers separated by an underscore character.
1) I believe the first number (100000079215099) is the id of a facebook user, is this always the case?
2) What does the second number (345415575486050) represent?
3) Once I have the full id (100000079215099_345415575486050) is it possible to use this id in another Facebook Graph API to retrieve the data associated with this id? If so, what would that url look like?
On facebook Evry user has ID and every event associated with it may be a status or photo also has an ID.
100000079215099_345415575486050
The first part of it represents the user id and second part represents the Event(Activity like a status or post) Id.
To Understand Better go to https://developers.facebook.com/graph-academy
Answers to your question:
1) First one will always be user id.
2) Mentioned above this is specific event related id. (Status or pic)
3) Yes, you can use this id everywhere in other APIs.
1) Yes the first number is the ID.
2) I'm not sure, I think it may be something to track where the view came from and who the viewer is. Perhaps an access token.
3) https://graph.facebook.com/100000079215099
https://graph.facebook.com/100000079215099_49874987249823749283
{
"error": {
"message": "(#803) Some of the aliases you requested do not exist: 100000079215099_49874987249823749283",
"type": "OAuthException"
}
}
https://graph.facebook.com/100000079215099_345415575486052
false
https://graph.facebook.com/100000079215099
returns her data, but I'm omitting it