Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in update snippet (tags) [PHP] #42

Open
StevenFlecha opened this issue Sep 24, 2015 · 0 comments
Open

Error in update snippet (tags) [PHP] #42

StevenFlecha opened this issue Sep 24, 2015 · 0 comments

Comments

@StevenFlecha
Copy link

In the PHP video snippet update example that adds tags it states:

      $video = $listResponse[0];
      $videoSnippet = $video['snippet'];
      $tags = $videoSnippet['tags'];
      // Preserve any tags already associated with the video. If the video does
      // not have any tags, create a new list. Replace the values "tag1" and
      // "tag2" with the new tags you want to associate with the video.
      if (is_null($tags)) {
        $tags = array("tag1", "tag2");
      } else {
        array_push($tags, "tag1", "tag2");
      }
      // Set the tags array for the video snippet
      $videoSnippet['tags'] = $tags;
      // Update the video resource by calling the videos.update() method.
      $updateResponse = $youtube->videos->update("snippet", $video);

I can't see how that is ever gonna work, seems like its written by a JS programmer :)
$video isn't changed proposed change:

$video = $listResponse[0];
$tags = $video[''snippet']['tags'];
if (is_null($tags)) {
      $tags = array("tag1", "tag2");
} else {
     array_push($tags, "tag1", "tag2");
}
$video[''snippet']['tags'] = $tags;
$updateResponse = $youtube->videos->update("snippet", $video);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant