Google Youtube API nextPageToken - youtube

I have read a lot of the other post about using the nextPageToken with the Youtube API.
The reference I am using is
https://developers.google.com/apis-explorer/?hl=en_US#p/youtube/v3/youtube.commentThreads.list?part=snippet&maxResults=100&order=time&videoId=xyvQaVUeu90&fields=items(id%252Csnippet%252FtopLevelComment%252Fsnippet%252FtextDisplay)%252CnextPageToken&_h=35&
The video id i am using is xyvQaVUeu90
The script I run returns a nextPageToken as
QURTSl9pMm1EbHlJZFdJTENzcHpIMGI3VWllOVl0enBxREN3NlZSYzAzZVdQTkNKNV9XQkpmQTNYLWhhVDIzeGN5eUdXUDZqWUJkdFdBOGdKVksyOENUU3B4b014Yi12Y05PdGRRcVlTaHp3VXEyR0JxRFVYMm5rWG1sbUZsRmk
So according to the API, if I use that nextPageToken it should return the next page of comments, however when I place the nextPageToken as the pageToken
Reference:
https://developers.google.com/apis-explorer/?hl=en_US#p/youtube/v3/youtube.commentThreads.list?part=snippet&maxResults=100&order=time&pageToken=QURTSl9pMm1EbHlJZFdJTENzcHpIMGI3VWllOVl0enBxREN3NlZSYzAzZVdQTkNKNV9XQkpmQTNYLWhhVDIzeGN5eUdXUDZqWUJkdFdBOGdKVksyOENUU3B4b014Yi12Y05PdGRRcVlTaHp3VXEyR0JxRFVYMm5rWG1sbUZsRmk&videoId=xyvQaVUeu90&fields=items(id%252Csnippet%252FtopLevelComment%252Fsnippet%252FtextDisplay)%252CnextPageToken&_h=36&
It returns:
{
"error": {
"errors": [
{
"domain": "youtube.parameter",
"reason": "invalidPageToken",
"message": "The request specifies an invalid page token.",
"locationType": "parameter",
"location": "pageToken"
}
],
"code": 400,
"message": "The request specifies an invalid page token."
}
}
Any help would be nice!

It's working perfectly. Just make sure to copy everything between the double quotes ("") . I was able to use it without problems. For example the nextPageToken provided in your link is
"QURTSl9pMFZuQUJYNGc4dDVZRjRjYlJ3d0M1MlIzeTRSeEJfclZOeEEzdncxRVM4bGZFOXdIRVVVRkJibjBSVW5xaEtBTE1zS0VTd2lDNndrRmJQaG4tY1dScXFral9hMVQ3NmJidFI1Vk83a0xhWEJNU2cwMlYweERGLU1uMDhLazg="
but you only copied
QURTSl9pMFZuQUJYNGc4dDVZRjRjYlJ3d0M1MlIzeTRSeEJfclZOeEEzdncxRVM4bGZFOXdIRVVVRkJibjBSVW5xaEtBTE1zS0VTd2lDNndrRmJQaG4tY1dScXFral9hMVQ3NmJidFI1Vk83a0xhWEJNU2cwMlYweERGLU1uMDhLazg
You did not include =

Related

I can't get this Google Sheets API Get request to work

I am trying to have a game to request data from the Google Sheets API, and I can't get the API Key to function properly. I can visit my API Link in the browser, and it tells me it is getting HTTP 400 (Bad Request) and Google additionally says it's a bad API Key, despite having JUST generated it. For reference my link looks like this: "https://sheets.googleapis.com/v4/spreadsheets/[SHEET_ID]?key=[API_KEY]/values", and the browser views this when using it:
"error": {
"code": 400,
"message": "API key not valid. Please pass a valid API key.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "API_KEY_INVALID",
"domain": "googleapis.com",
"metadata": {
"service": "sheets.googleapis.com"
}
}
]
}
}
I have absolutely no idea what is going wrong, I know the API key and Sheet ID are right (Directly copied each from their respective source).

Cannot delete comment on Youtube video via API

I'm trying to delete followiing comment z12mdhjgxrfgtpf3d231jrz5vo3jdj0lo on this video but the response code is 400. I'm using token of the channel's admin with https://www.googleapis.com/auth/youtube.force-ssl scope as it required by documentation.
The request is:
DELETE https://www.googleapis.com/youtube/v3/comments?id=z12mdhjgxrfgtpf3d231jrz5vo3jdj0lo&alt=json
{
"query_params": {
"id": "z12mdhjgxrfgtpf3d231jrz5vo3jdj0lo",
"alt": "json"
}
}
The response:
{
"error": {
"errors": [
{
"domain": "youtube.comment",
"reason": "processingFailure",
"message": "The API server failed to successfully process the request. While this can be a transient error, it usually indicates that the requests input is invalid.",
"locationType": "parameter",
"location": "id"
}
],
"code": 400,
"message": "The API server failed to successfully process the request. While this can be a transient error, it usually indicates that the requests input is invalid."
}
}
What is wrong with the request?
That's token debug info:
{
issued_to: "493985796851.apps.googleusercontent.com",
audience: "493985796851.apps.googleusercontent.com",
user_id: "109704411339866376304",
scope: "https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/youtube.force-ssl https://www.googleapis.com/auth/youtube.upload",
expires_in: 2452,
access_type: "offline"
}
The reason you're not able to delete the comment is that you're using Comments.delete to remove comment which was written by other users . Comments.delete only deletes your own comments in your video.
To delete comment of other users, use Comments.setModerationStatus and set moderationStatus to "rejected".
So just repeat what you did but this time using Comments.setModerationStatus. There's a Try-it in the link for testing purposes.

Why Youtube "channels" API don't return "contentOwnerDetails" data?

I'm trying to make this call to Youtube channels API but the response is without contentOwnerDetails. What is the problem?
GET https://www.googleapis.com/youtube/v3/channels?part=id%2CcontentDetails%2CcontentOwnerDetails&mine=true&key={YOUR_API_KEY}
It looks like it needs onBehalfOfContentOwner parameter. My request was
GET https://www.googleapis.com/youtube/v3/channels?part=snippet%2CcontentOwnerDetails&id=CHANNEL_ID&onBehalfOfContentOwner=NETWORK_ID
And I was able to get
"contentOwnerDetails": {
"contentOwner": NETWORK_ID,
"timeLinked": "2015-07-23T15:21:25.000Z"
}
For your GET method URI
https://www.googleapis.com/youtube/v3/channels?part=id%2CcontentDetails%2CcontentOwnerDetails&mine=true&key={YOUR_API_KEY}
The JSON response is as follows
{
"error": {
"errors": [
{
"domain": "youtube.parameter",
"reason": "authorizationRequired",
"message": "The request uses the <code>mine</code> parameter but is not properly authorized.",
"locationType": "parameter",
"location": "mine"
}
],
"code": 401,
"message": "The request uses the <code>mine</code> parameter but is not properly authorized."
}
}
According to YouTube Data API - Errors
401 (unauthorized) - authorizationRequired - The request uses the mine
parameter but is not properly authorized.
mine parameter value has to be set to true to instruct the API to only return channels owned by the authenticated user. (boolean)
Inference: You don't have the authorization to the content from the content owner, i.e., the YouTube Channel owner has probably denied permission to your application from accessing the channels content.
It's a permission issue. Where is the channelId in the URI? should probably add it.
If you don't own the channel the API will not return contentOwnerDetails. Since you're using mine=true parameter, you need to be properly authorized via OAuth first before the API will return contentOwnerDetails. See https://developers.google.com/youtube/v3/guides/authentication

trying to show more than 50 results corresponding to single topic id using freebase in android

I want to get more than 50 youtube video results corresponding to topic id ........so i am trying to get next page token.......
in youtube api v3 in android
and url used is....
https://www.googleapis.com/youtube/v3/videos?part=id,snippet&order=relevancee&topicId="+topicId+"&q="+videoId+"&key="
but the error giving is......
"error": {
"errors": [
{
"domain": "youtube.parameter",
"reason": "missingRequiredParameter",
"message": "No filter selected.",
"locationType": "parameter",
"location": ""
}
],
"code": 400,
"message": "No filter selected."
}
}
You should set type = video
Whenever you are using a video specific filter you have to filter type as well. As search is unified, otherwise it normally returns playlist, channel and videos as a result.
You can always try your queries in API explorer before implementing.

Searching for HD videos using the YouTube API v3?

I am getting invalid combination of search filter error while retrieving the HD videos. this was the url - https://www.googleapis.com/youtube/v3/search?part=snippet&q=drama&videoDefinition=high&key={Developerkey}
Error report
{
"error": {
"errors": [
{
"domain": "youtube.search",
"reason": "invalidSearchFilter",
"message": "Invalid combination of search filters and/or restrictions.",
"locationType": "parameter",
"location": ""
}
],
"code": 400,
"message": "Invalid combination of search filters and/or restrictions."
}
}
Is it possible to retrieve HD videos? Please guide me. How can I get a response from this URL? Thanks
You also need to include the type=video query parameter, since filtering on high definition only makes sense when the results are limited to videos.
That being said, the error message that's returned isn't actually helpful, and I'll ask the engineering team to revise it so that it clarifies what's wrong.

Resources