GMB MyBusiness API - How to set up real-time PubSub notifications? - google-cloud-platform

I am working on integrating GMB into some of our internal apps, and would like to set up to receive real-time notifications for reviews and questions.
I have created a topic, and a subscription with a valid URL.
The next step is to tell GMB to send the notifications to the topic, and I believe the endpoint is the one below. However, it is very vague about the parameters it wants.
This is the documentation
https://developers.google.com/my-business/reference/rest/v4/accounts/updateNotifications
It wants a "Notification Settings Resource Name" in the URL, but it's not explained anywhere what that actually is. I have tried every possible value, but always get a 404 error response with the message "Requested entity was not found."
Has anyone successfully set this up? What values does the "getNotifications" endpoint want, and where in the various dashboards can this be found or created?
Any help is much appreciated!

As mentioned in the comments, you need to send the accountId as part of the URL.
To find this, you will first need to send a GET request to
https://mybusiness.googleapis.com/v4/accounts
This will return something along the following lines:
{
"accounts": [
{
"name": "accounts/102647145453118950380",
"accountName": "Tom Spencer",
"type": "PERSONAL",
"state": {
"status": "UNVERIFIED",
"vettedStatus": "NOT_VETTED"
},
"profilePhotoUrl": "//lh3.googleusercontent.com/a-/AOh14GgPkuJj03DeCa1isBAJALY4eOl09WGYVFrM4mG5=s132"
},
]
}
You can see here that accounts/102647145453118950380 is returned in the name field. Take this field, and construct the following URL:
https://mybusiness.googleapis.com/v4/accounts/102647145453118950380/notifications
Send a PUT request to this URL, with a request body resembling the following:
{
"topicName": "projects/{projectId}/topics/{topicId}",
"notificationTypes": [
"NEW_REVIEW",
"UPDATED_REVIEW"
]
}
Assuming you have pub/sub setup as per the documentation, this should send a message to your topic/subscribers whenever a new review is created or a review is updated.

Related

Getting unexpected '#' error under postman Test tab

I am a learner in postman and do not have much experience in programming/scripting.
Here the issue.
Used POST api request - For getting the access token;
Used POST api request - To create an account;
Used POST api request - To cancel an account with CancellationReason
Need to crosscheck the cancellation details (some fields like cancellationReason) in web application.
In order to avoid manually check, i have used GET request api like below
by passing all the mapped fields (as per web application) in the GET request end url
(i.e. by sending the details in fetch_xml query parameter in the end url) in order to get those required fields returned.
Now i got a successful response with status code.
After that i want to compare the fetched values (from the response body) ... VS.... to the data i passed while cancelling the account (i.e. in POST api request - To cancel the account) and make sure both are same.
After that under Test tab - I have updated query like below, however it throwing an Unexpected '#' error (as the below query contains '#' in middle of the field name)
tests["Verify the CancellationReason matches"] = pm.expect(data._usr_cancellationReason_value#OData.Community.Display.V1.FormattedValue).to.eql("CancellationReason");
Can someone please help me to understand whether i should remove this #symbol or should replace with something else ?
Here is the response body:
{
"#odata.context": "https://hfrdcompanies.integrationdev01.crm3.cs.com/api/data/v9.1/$metadata#hfrd_workorders(_usr_cancellationchannel_value,usr_CancellationChannel,_usr_workorderreason_value,usr_WorkOrderReason,hfrd_workorderid,usr_cancellationuser,_usr_cancellationsource_value,usr_CancellationSource,hfrd_name,usr_CancellationChannel(),usr_AccountReason(),usr_CancellationSource())",
"value": [
{
"#odata.etag": "W/\"2345234523\"",
"_usr_cancellationchannel_value#OData.Community.Display.V1.FormattedValue": "Mobile App",
"_usr_cancellationchannel_value": "acefsdflin89-f9jf07-e969f1-a245nk11-00jnfnafn9799fc2a",
"_usr_Accountreason_value#OData.Community.Display.V1.FormattedValue": "Customer Inactive",
"_usr_Accountreason_value": "bde1234522-d45662-e2711-a84561-0007354a2d5c2a",
"hfrd_Accountid": "89025sf3-c668f-e7811-a4331-00asdhh3ab9bd1c",
"usr_cancellationuser": "Testuser08 ABC",
"_usr_cancellationsource_value#OData.Community.Display.V1.FormattedValue": "MOBILE",
"_usr_cancellationsource_value": "6c23asdf-c562-e411-a841-00asdfa",
"hfrd_name": "FP-WK-1000000642"
}
]
}
I want to validate the bold row

Add Status using Facebook API

I am learning Rest web services using Postman extension of Chrome. I'm practicing it using Facebook API. I have a question about posting in FB.
URI used: https://graph.facebook.com/me/feed?
In the Body of the POST Method, I have given the following Json content
{
"message": "hello",
"access_token": "<a valid token>"
}
I am very sure that my access token is correct as when I append the access token and message with the above URI, the status gets posted successfully. Also when I use it as key-value pairs in 'x-wwww-form-urlencoded' section, it works fine.
But when I try to update the status using the Body of the POST method with the JSON content mentioned above, it tells
{ "error": { "message": "An active access token must be used to query information about the current user.", "type": "OAuthException", "code": 2500 } }
Is there any thing wrong in the format of the JSON content
I missed content-type=application/json
in the Header section.
Adding this solved the problem

couldn't receive google glass notification after subscription?

I have created a timeline card with menu item and subscribed the same.When i try it(clicked the menu item) from mirror api playground ,it shows notification send but my service couldn't receive any notification.Its not showing any sign of hitting my service log also.
Below is my subscription json.
{
"kind": "mirror#subscription",
"id": "timeline",
"updated": "2013-12-19T06:27:20.269Z",
"collection": "timeline",
"operation": [
"UPDATE"
],
"callbackUrl": "https://mirrornotifications.appspot.com/forward?url=http://192.xxx.xx.xxx:8080/GlassService/google/service/get_balance",
"verifyToken": "example_user",
"userToken": "email"
}
instead of ip address in the callback url i tried with localhost also.i got same result.
Please help me with this.
Thanks in advance.
Google subscription does not support local url or proxy. You have to submit public url with SSL support for callback Like "https://www.yourdomain.com/yourmethod".
Another way is, you can use "Introspected tunnels to localhost". then your local url become public and you will get notification after subscription.

"privacy" is not accepted, when posting to a Page's wall with a Pagetoken

Goal:
I want to specify privacy for posts, that are done through my application, when I post to a Page's wall, using Pagetoken.
Problem:
Using page token, I do post to URL "https://graph.facebook.com/me/feed"
with the following body —
{
"message": "from app with security after requesting a username",
"privacy": {
"description": "Amsterdam, Netherlands, Netherlands",
"value": "CUSTOM"
}
}
An receive such a terrible answer —
{
"error": {
"message": "(#100) Posts where the actor is a page cannot also include privacy.",
"type": "OAuthException"
}
}
Even through it is said in documentation, here - https://developers.facebook.com/docs/reference/api/page/#posts,
that Pages#post.privacy is supported.
And explicitly:
"The description field may contain a comma-separated lists of valid country, city and language if a Page's post targeting by location/language is specified."
Please help me out, what am I doing wrong?
I posted the bug in Facebook Developers Bug reporter tool
https://developers.facebook.com/bugs/238365492903384
Subscribe/Comment to push this for a reply
This looks like a documentation bug. I have attached a screenshot of the old version of the docs. Try using "targeting" with the same location format as:
https://developers.facebook.com/docs/adsapi/targeting_specs/
I've also requested a fix for the docs.

Facebook Graph API - get ID for a URL?

This seems like a pretty obvious, basic thing to expect from the Graph API, but I'm having serious difficulty with it. All I want to do is get the ID for any particular URL. They have a method for this:
https://graph.facebook.com/?ids=http://www.imdb.com/title/tt0117500/
And that works great. But if I try another URL, say for my blog,
https://graph.facebook.com/?ids=http://dusda.vox.com
it doesn't give me back a numerical ID like all of the examples do. Instead, this:
{"http:\/\/dusda.vox.com":{"id":"http:\/\/dusda.vox.com"}}
If I try to use that "id", I get jack (probably because the query string looks impossible to parse):
Request: https://graph.facebook.com/http://dusda.vox.com/likes
Response: {"id":"http:\/\/dusda.vox.com\/likes"}
So what's up with this? Is the Graph API just selectively reliable, or am I misunderstanding something? I've tried it on URLs that I know are popular on Facebook, too, and I've gotten mixed results.
Try FQL for this;
http://graph.facebook.com/fql?q=select%20url%2C%20id%2C%20type%2C%20site%20from%20object_url%20where%20url%20%3D%20%22http%3A%2F%2Fkriek.hu%2F%22
returns:
{
"data": [
{
"url": "http://kriek.hu/",
"id": 497425470154,
"type": "link",
"site": "kriek.hu"
}
]
}
For more information, see object_url.
I hope it helps!
The ID is given by Facebook only to pages which have a fbshare/like button. Else the API returns the number of shares and the request URL.
If I use the facebook object debugger page I can scrape every url, for example:
https://developers.facebook.com/tools/debug/og/object?q=ddnl.de
The page give me back an url with ID and so I can get every needed parameters.
In this case https://graph.facebook.com/10150164108649475
But I don't get this ID or url with FQL or otherwise?
Very old question, but here's what I found works for me as none of the answers here really resolved my issue:
If you have a custom object tied to a url, the method suggested by Pepe only gives the id FB assigns to the url where type=link. (Which is not tied to any comments)
In my case, I need my custom object id so that I could pull associated comments from it. You can get the object id using FQL by doing a select on 'comments_fbid' from the 'link_stat' table. (This will return the object id even if no comments have been added so it should work for other cases)
api.facebook.com
At this time no of the suggested solutions work for all urls. Only the Debugger is able to get the Graph ID correctly
For example
Debugger:
https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.amazon.de%2Fgp%2Fproduct%2F3810510793%2F
For URL:
www.amazon.de/gp/product/3442465583/
Result:
https://graph.facebook.com/10150771435736113
{
"url": "http://www.amazon.de/dp/3810510793/ref=tsm_1_fb_lk",
"type": "book",
"title": "Die unwahrscheinliche Pilgerreise des Harold Fry: Roman",
"image": [
{
"url": "http://ecx.images-amazon.com/images/I/51I4E81xrRL._SL160_.jpg"
}
],
"description": "Die unwahrscheinliche Pilgerreise des Harold Fry: Roman",
"site_name": "Amazon.de",
"updated_time": "2012-12-19T16:54:27+0000",
"id": "10150771435736113",
"application": {
"id": "164734381262",
"name": "Amazon",
"url": "https://www.facebook.com/apps/application.php?id=164734381262"
}
}
I had the same problem here, I was trying to get the same data IMDB gets. After almost bang my head against the wall, I decided to look at the facebook's js function. And look what I get, the explanation is on the link.
Getting limited data from a page which has a Facebook ID
Peace