How to look up user information from Google GAIA ID? - php

I've been working on a Hangouts.json parser for Google's Takeout service that takes all of the conversations, attachments, and miscellaneous information from the json file and populates a database with everything. I've finished everything but the only information the json file provides for who sent what is a GAIA ID that I've been able to figure out is the unique ID Google uses between their services. The problem is I don't know how to look up any other information about the user such as the name they identify with or their email.
I know most of the information is publicly available as you can take the GAIA ID and put it into a URL like: https://plus.google.com/u/0/#####################/about where the #'s are the GAIA ID. This page will reveal their screen name publicly. When a email address is unknown the same thing can be inferred by using: reply-######################profiles.google.com where this will also be able to be used to contact them.
Ideally I'd like to be able to look up a user's screen name without having to parse that public Google+ page at least but a true email would be great as well. So ideally I'd like an API or other resource to look up screen names and / or email info from a GAIA ID.

IMPORTANT UPDATE
March 2019: This answer is still getting up votes, however Google are withdrawing / have withdrawn the Google Plus API.
You will need an alternative solution as this will no longer apply.
Original Reply
Use the Google Plus API: https://developers.google.com/+/api/
I've not tested specifically with Hangouts (I never knew there was a Hongouts API!) but it returns details given IDs from other APIs.
You can test it out here: https://developers.google.com/apis-explorer/#p/plus/v1/plus.people.get to see what you'll get.

The Gaia ID may be obtained with the People API, by requesting the metadata in the personFields.
You may try it with the Google APIs Explorer (sample links are provided below).
For any of your contacts (provided he/she is a google user), using the people.connections/list resource :
People API - people.connections/list - personFields=names,metadata
(I have included the names value in the personFields for better illustration, though it is not required to retrieve the Gaia Id)
Sample output (1XXXXXXXXXXXXXXXXXXXX is the Gaia Id):
{
"connections": [
{
"resourceName": "people/c42",
"etag": "...",
"metadata": {
"sources": [
{
"type": "CONTACT",
...
},
{
"type": "PROFILE",
"id": "1XXXXXXXXXXXXXXXXXXXX",
...
"profileMetadata": {
"objectType": "PERSON",
"userTypes": [
"GOOGLE_USER"
]
}
}
....
],
"objectType": "PERSON"
}
"names": [
{
...
"displayName": "John Doe",
...
}
]
},
...
}
For yourself or any user using the people/get resource
People API - people/get - personFields=metadata
In the resourceName field :
use people/me to obtain your informations.
use the resourceName value previously retrieved in a people.connections.list request to retrieve another user informations
Sample output (1XXXXXXXXXXXXXXXXXXXX is the Gaia Id):
{
"resourceName": "people/...",
"etag": "....",
"metadata": {
"sources": [
{
"type": "PROFILE",
"id": "1XXXXXXXXXXXXXXXXXXXX",
"etag": "...",
"profileMetadata": {
"objectType": "PERSON",
"userTypes": [
"GOOGLE_USER"
]
}
...
},
...
],
"objectType": "PERSON"
}
}

Go to google chat.
create a chat with the person you want to find gaia id.
tag the person in the chat window
(#name of person)
right click the name, click "Inspect"
There you will find the ID
data-user-id="10xxxxxxxxxxxxxxxxxxx
#Name of person

Related

How to get Instagram comment parent id and identify if it top-level or reply

I'm working on Instagram API, I need to identify whether the comment of a specific id is a top-level comment or reply on a comment, in case it is a reply then what is the parent comment id.
I searched about any related fields in the API documentation (link below) but nothing meets these needs.
https://developers.facebook.com/docs/instagram-api/reference/comment/
All details API provides is the edge "replies" which get the children, while what I'm looking for is to know if it is top-level or reply comment and get the parent comment id if it has.
Now the "parent_id" field is available as part of the Webhook's payload.
All you need to do is to subscribe on Instagram Webhooks product to the "comments" field on your Facebook developer app and you'll receive the "parent_id" property if this comment was created on another IG comment.
{
"field": "comments",
"value": {
"from": {
"id": "232323232",
"username": "test"
},
"media": {
"id": "123123123",
"media_product_type": "FEED"
},
"id": "17865799348089039",
"**parent_id**": "1231231234",
"text": "This is an example."
}
}
https://developers.facebook.com/docs/graph-api/webhooks/reference/instagram/#comments
ID of parent IG Comment if this comment was created on another IG Comment (i.g. a reply to another comment)

Watson Assistant CURL API: How to send follow up message?

I'm trying out IBM Watson Assistant. Ultimate goal is to integrate it with my custom PHP backend, via it's Watson Assistant's cURL API Endpoints (because there's no complete PHP SDK yet).
Let me tell what I did so far:
Imported a sample Workspace from a Training Data Set.
Then I tried this, and it works fine.
Then I tried that exact same thing via cURL API, I got a response like this: (The json output format beautified)
.
{
"intents": [
{
"intent": "locate_amenity",
"confidence": 0.999901008605957
}
],
"entities": [
{
"entity": "amenity",
"location": [
7,
10
],
"value": "gas",
"confidence": 1
}
],
"input": {
"text": "i need some gas"
},
"output": {
"text": [
"Hi. It looks like a nice drive today. What would you like me to do? "
],
"nodes_visited": [
"Start And Initialize Context"
],
"log_messages": []
},
"context": {
"conversation_id": "153c18ee-1015-4b6a-ae04-789e29bf4a05",
"system": {
"dialog_stack": [
{
"dialog_node": "root"
}
],
"dialog_turn_counter": 1,
"dialog_request_counter": 1,
"_node_output_map": {
"Start And Initialize Context": [
0,
0
]
},
"branch_exited": true,
"branch_exited_reason": "completed"
},
"AConoff": "off",
"lightonoff": "off",
"musiconoff": "off",
"appl_action": "",
"heateronoff": "off",
"volumeonoff": "off",
"wipersonoff": "off",
"default_counter": 0,
"previous_cuisine": "",
"previous_restaurant_date": "",
"previous_restaurant_time": ""
}
}
Now please let me understand 2 things here.
Question (1)
At this point, I was expecting the API to return with a message:
"There are gas stations nearby. Which one would you like to drive to?"
But why it doesn't. If then, how do I achieve it?
Question (2)
How do I properly reply back with "Go to number 5." so that the API understands I'm referring to the previous Call? (aka) How to I continue the dialog flow? (Note: I tried sending back with the previous "contexts", "entities", "intents", but it is somehow still recognised as a new message.)
Please share me an example of cURL call to follow up the previous message.
Since there's no complete PHP SDK yet, it is very hard for me to understand just by the cURL API calls. API Documentation does not explain to that details too. Please help.
Thank you all.
The message API for Watson Assistant is stateless. Everything that is needed to process a request is submitted as parameters. This includes the message itself, but also the context. The context holds the state about where in the dialog tree the conversation is. It could also hold information that is transferred from WA to the app, e.g., to process a client-side action. Or from the app to WA, e.g., with a record from a database.
Coming to your request:
Your dialog probably sends out that reponse when a new conversation is started. I see it is the same as in the "Try it out".
You would need to send a "Hi" or empty message first, wait for the reponse from WA, then send your "I need gas" together with the context data you received from WA. WHen you look into the details, you see the dialog stack, turn counter and more. The conversation ID is the identifier for that current chat.
With the above, WA's next response should be exactly like in the "Try it out" because you went down in the dialog tree.

How to check if a Team drive is Trashed in Google Drive REST API?

Is their a way to check by making an API call to google Drive that if a particular Team Drive is Trashed or not?
I have tried to do a GET request to the particular Team drive which is trashed by the user. But I get 200 response, So how can I detect the team-drive was trashed by user
GET https://www.googleapis.com/drive/v2/teamdrives/{trashed-team-drive-id}
By using the Changes: list, you can check here your most recent file/folder changes. Including the changes for folder movements as well as trashed files.
Here are the steps that you need to do:
Use Changes: getStartPageToken and pass the value true to the supportsTeamDrives parameter. Just get the value that you will get from it because you will use it in the next step. eg. "startPageToken": "1203685"
You can now use the Changes: list to get the changes in your teamDrive. Here are the parameter that you need to pass:
pagetoken - 1203685 // the value that you get in the above step.
includeRemoved - true
includeTeamDriveItems - true
supportsTeamDrives - true
teamDriveId - YOUR_TEAM_DRIVE_ID
After you execute this step, you will receive something like this:
{
"kind": "drive#changeList",
"newStartPageToken": "25",
"changes": []
}
Now, you need to use this 25 as your pagetoken, again you will receive the same results, because you are using the most recent page token. You need to manually reduce the page token until you received the changes.
Here are the sample parameter and sample results.
pagetoken - 25 // then use 24, to check the latest changes, then 23 and so on.
includeRemoved - true
includeTeamDriveItems - true
supportsTeamDrives - true
teamDriveId - YOUR_TEAM_DRIVE_ID
Sample results
{
"kind": "drive#changeList",
"newStartPageToken": "25",
"changes": [
{
"kind": "drive#change",
"type": "file",
"time": "2017-03-23T09:23:43.399Z",
"removed": true,
"fileId": "1JByPgn1GVybkprMC0NX_t0o6xxxxD6ZnuVqo1Kymjqk"
}
]
}
For more information, check this documentation about Team Drive.
Updated Answer
Well, the only way that I can see to determine if the Team Drive is deleted or not is by checking if it is available in the Teamdrives: list
You will see here all the available team drive that you have.
In my case I have three team drive so the result is like this:
{
"kind": "drive#teamDriveList",
"teamDrives": [
{
"kind": "drive#teamDrive",
"id": "0AMlDYsxxxxLYUk9PVA"
},
{
"kind": "drive#teamDrive",
"id": "0ABe6rxxxxzGaUk9PVA"
},
{
"kind": "drive#teamDrive",
"id": "0ABgqxxxxgt-NUk9PVA"
}
You can also verify it if you know the id of the team drive by using the Teamdrives: get
I tried to delete one of the team drive "0AMlDYsxxxxLYUk9PV" and perform again the
Teamdrives: list. Now, I only get the two results
{
"kind": "drive#teamDriveList",
"teamDrives": [
{
"kind": "drive#teamDrive",
"id": "0ABe6rxxxxzGaUk9PVA"
},
{
"kind": "drive#teamDrive",
"id": "0ABgqxxxxgt-NUk9PVA"
}
And if I use now the Teamdrives: get for the teamDriveId "0AMlDYsxxxxLYUk9PV", I will now receive an error 404: "Team Drive not found: 0AMlDYsxxxxLYUk9PV"
Hope this information helps you.

Facebook API Webhook - Get Post ID

Can I get a specific post ID from a Webhook, currently I can make an API call and get all the data I need and store it locally to display to the user, however if I decide to use Webhbook to get new updates all they give me is a UID and ID which are both the same.
Is there any way to retrieve the specific post/notification ID through Webhook? Or does it only really tell you that you its time to make another API call and update/compare your records?
Here is an example of what I am returned -
{
"object": "user",
"entry": [
{
"uid": "123456789",
"id": "123456789",
"time": 1374846331,
"changed_fields": [
"feed"
]
}
]
}
Thanks.

How to get user's network information using Facebook Graph API? (PHP)

I have been playing with Facebook Graph API around a week, and I still could not find how to get user's network information? I don't know if the Graph API stores user's network; I didn't see such information. Simply, if a user is in "Google" network, may I get the name and the ID of the networks that the user belongs to?
If this is not possible, may I reach the user's secondary email addresses?
Thanks for your help.
Using FQL : the affiliations field of the User table contains this information
Sample call:
https://graph.facebook.com/fql?q=select affiliations from user where uid= 4&access_token=<ACCESS TOKEN>
Sample response:
{
"data": [
{
"affiliations": [
{
"nid": 16777217,
"name": "Harvard",
"type": "college"
},
{
"nid": 50431648,
"name": "Facebook",
"type": "work"
}
]
}
]
}

Categories