Kristians
Kristians

Reputation: 794

Can't upload or update video with tags

I'm uploading the video through my app using the documented PHP API library with pretty much the same code as here; https://developers.google.com/youtube/v3/code_samples/php#updating_a_video_by_adding_new_tags.

The uploaded video receives the title, description and playlist correctly, but not the tags.

Any clues at all?

Edit: I'm wondering if it has anything to do with scope, does it matter if i've authorized with https://www.googleapis.com/auth/youtube or https://www.googleapis.com/auth/youtube.upload?

This question: Youtube Google API V3: List Videos not returning video tags gets an answer suggesting the "onBehalfOfContentOwner" parameter, however, i'm getting "HTTP 403: youtube.common, Access forbidden. The request may not be properly authorized" when trying to upload with that parameter ($insertRequest = $youtube->videos->insert('status,snippet', $video, ['onBehalfOfContentOwner' => true]);)

Upvotes: 1

Views: 117

Answers (1)

Kristians
Kristians

Reputation: 794

I found the problem, not sure why it is a problem though; when setting the tags i was doing an array filter, when i removed that as a desperate test or "am i blind and using the wrong array_* function", the tags came through

So changing

$snippet->setTags(array_filter($medium['properties']['keywords']));

to

$snippet->setTags($medium['properties']['keywords']);

did the trick... I could reproduce the problem by re-adding the array_filter, and i made sure to check so it wasn't actually empty,

var_dump(array_filter($medium['properties']['keywords']), $medium['properties']['keywords']);

yielded the same result

Upvotes: 1

Related Questions