googleplus api giving nextPageToken even when there is not data - google-api

Why is Googleplus api giving nextPageToken when there is no results ?
{
"kind": "plus#activityFeed",
"etag": "\"gLJf7LwN3wOpLHXk4IeQ9ES9mEc/E_vEAk7R5aEXkBfh8ZRN5jeozRI\"",
"nextPageToken": "ChAQt73bzsytxwIYACCTASgHEg4IABAAGP__________fxgCIAAo0Z7qjYvxrPfUAQ==",
"selfLink": "https://www.googleapis.com/plus/v1/activities?orderBy=recent&pageToken=Cg8Qt73bzsytxwIYACB-KAYSDggAEAAY__________9_GAIgACjRnuqNi_Gs99QB==&key=AIzaSyDf3ejxhljBJ31CIRqx3-g7zXVTvq08HA0&query=%2B971-800-7669&alt=json&maxResults=20",
"title": "Google+ Activities Search Results",
"items": []
}

Related

YouTube Data API Get Channel by Handle

Introducing handles: A new way to identify your YouTube channel
Does the YouTube Data API support querying for a channel by it's #handle? This does not seem to be supported.
ex: https://www.youtube.com/#lionsgatemovies
forUsername param
GET https://www.googleapis.com/youtube/v3/channels?part=id,snippet&forUsername=#lionsgatemovies
{
"kind": "youtube#channelListResponse",
"etag": "RuuXzTIr0OoDqI4S0RU6n4FqKEM",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
}
}
id param
GET https://www.googleapis.com/youtube/v3/channels?part=id,snippet&id=#lionsgatemovies
{
"kind": "youtube#channelListResponse",
"etag": "RuuXzTIr0OoDqI4S0RU6n4FqKEM",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
}
}
None of the supported filter params seem to be appropriate:
{
"error": {
"code": 400,
"message": "No filter selected. Expected one of: mySubscribers, forUsername, mine, managedByMe, categoryId, id",
"errors": [
{
"message": "No filter selected. Expected one of: mySubscribers, forUsername, mine, managedByMe, categoryId, id",
"domain": "youtube.parameter",
"reason": "missingRequiredParameter",
"location": "parameters.",
"locationType": "other"
}
]
}
}
You can use Search API with q parameter set to #handle
curl \
'https://youtube.googleapis.com/youtube/v3/search?part=snippet&maxResults=25&q=%40kevinrooke&type=channel&key=[YOUR_API_KEY]'
{
"kind": "youtube#searchListResponse",
"etag": "AYlro9VG2vMtdew4OQiWoQM8Rs0",
"regionCode": "LT",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "ls9E_ctoa-RLsqznJwxWlHHIE1s",
"id": {
"kind": "youtube#channel",
"channelId": "UCTdxV_ItCZMayyzGkw7P_qQ"
},
"snippet": {
"publishedAt": "2017-05-27T03:56:38Z",
"channelId": "UCTdxV_ItCZMayyzGkw7P_qQ",
"title": "Kevin Rooke",
"description": "Interviews with the builders bringing the Lightning Network to life. ⚡kerooke#fountain.fm.",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu-SpmaNjx7KOMqs5Cr7ZthU60BaQApzt89_dHOlcg=s88-c-k-c0xffffffff-no-rj-mo"
},
"medium": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu-SpmaNjx7KOMqs5Cr7ZthU60BaQApzt89_dHOlcg=s240-c-k-c0xffffffff-no-rj-mo"
},
"high": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu-SpmaNjx7KOMqs5Cr7ZthU60BaQApzt89_dHOlcg=s800-c-k-c0xffffffff-no-rj-mo"
}
},
"channelTitle": "Kevin Rooke",
"liveBroadcastContent": "none",
"publishTime": "2017-05-27T03:56:38Z"
}
}
]
}
As of this moment (17th Nov 2022), YouTube has yet to update the Data API with #handle support.
The channelId was scattered around in the Html. You can easily parse them after fetching the url with the handle.
const html = await(await fetch(url)).text()
const channelId = html.match(/(?<=channelId(":"|"\scontent="))[^"]+/g)[0];
Following is the python snippet while we are waiting for YouTube API's official support. This is inspired by goodhyun's wonderful thoughts.
import requests
import re
# return YouTube channel id via handle or False if failed
def scraping_get_channel_id_from_handle(handle:str):
if handle.find('#') == -1:
handle = '#' + handle
url = 'https://www.youtube.com/' + handle
resp = requests.get(url)
if resp.status_code == 200:
found = re.findall('"channelId":"([^"]*)","title"', resp.text)
return found[0]
else:
return False

Summary value of calendar object

I recognized that the return of CalendarList has changed. the summary value was person's name but now it returns email address.
my question is how can I get calendar name using calendar API?
tested url: https://developers.google.com/calendar/v3/reference/calendarList/list
◆ Before
{
"kind": "calendar#calendarList",
"items": [
{
"kind": "calendar#calendarListEntry",
"etag": "\"1578551131788000\"",
"id": "test#test.com",
"summary": "Test Calendar", // <-- calendar's name
"timeZone": "Asia/Tokyo",
◆Now
{
"kind": "calendar#calendarList",
"items": [
{
"kind": "calendar#calendarListEntry",
"etag": "\"1578551131788000\"",
"id": "test#test.com",
"summary": "test#test.com", // <-- email address
"timeZone": "Asia/Tokyo",
There is currently a bug in Google calendar. its not returning the title in the summary as it is documented to do Bug report can be found here.
Calendar.get on my primary calendar returns
{
"kind": "calendar#calendar",
"etag": "\"KfTgGrEyu1otuO_8YfN8ka6X3tg\"",
"id": "xxx#gmail.com",
"summary": "xxxx#gmail.com",
"description": "test",
"timeZone": "Europe/Copenhagen",
"conferenceProperties": {
"allowedConferenceSolutionTypes": [
"eventHangout"
]
}
}
The documentation states that a calendar resource should return
summary = Title of the calendar.

Bug: Google+ People Search API always returns 0 results

Requests to
https://www.googleapis.com/plus/v1/people?query=john+doe&key=[key]&maxResults=50
for whatever ?query always returns zero items[]
{
"kind": "plus#peopleFeed",
"etag": "\"ucaTEV-ZanNH5M3SCxYRM0QRw2Y/Zbzi1ZPF4WuKo3Uhmc0kd8tdybA\"",
"selfLink": "https://www.googleapis.com/plus/v1/people?query=john+doe&key=[key]&maxResults=50",
"title": "Google+ People Search Results",
"nextPageToken": "",
"items": []
}
This is also the case in the "Try this API" form located at https://developers.google.com/+/web/api/rest/latest/people/search

TIME_PERIOD_SHORT - from Events.Record

I have a request to the Google play games API Events.record that always returns with the error TIME_PERIOD_SHORT. Below is the Event Record Request Resource. Can you help me spot my error?
{
"timePeriods": [{
"timePeriod": {
"periodEndMillis": 1460691042546,
"periodStartMillis": 1460691039815,
"kind": "games#eventPeriodRange"
},
"updates": [{
"updateCount": 3,
"kind": "games#eventUpdateRequest",
"definitionId": "CgkIiLWAzPEJEAIQAg"
}],
"kind": "games#eventPeriodUpdate"
}],
"kind": "games#eventRecordRequest",
"requestId": 1460691043076,
"currentTimeMillis": 1460691043076
}
My response shows the following error even though in this example this batch period is 2731 millis. I've even pushed it out to 30 seconds and I still get this error.
{
"eventFailures": [],
"batchFailures": [{
"range": {
"periodEndMillis": "1460691042546",
"periodStartMillis": "1460691039815",
"kind": "games#eventPeriodRange"
},
"failureCause": "TIME_PERIOD_SHORT",
"kind": "games#eventBatchRecordFailure"
}],
"playerEvents": [],
"kind": "games#eventUpdateResponse"
}
}

Sorting Google API responses -

I am using the Google + API to fetch a users' public activities, using the appropriate endpoint.
However, Google returns the activities in no particular order - Here is a snippet:
{
"kind": "plus#activity",
"published": "2014-07-31T13:40:41.017Z"
},
{
"kind": "plus#activity",
"published": "2014-08-27T01:51:25.378Z"
},
{
"kind": "plus#activity",
"published": "2014-09-05T02:52:33.654Z"
},
{
"kind": "plus#activity",
"published": "2014-08-12T18:00:59.920Z"
},
{
"kind": "plus#activity",
"published": "2014-08-14T18:52:00.420Z"
},
{
"kind": "plus#activity",
"published": "2014-08-01T13:41:10.034Z"
},
//[...]
So what do I have to pass into the request to get Google to send me the response in order from most recent to oldest? -- or is this something I have to do, myself?
Based on the documentation and on this issue, I'd say this is not possible at the moment with the list method, only with search.

Resources