doujia7162 2012-12-21 17:05
浏览 30

如何用Youtube Api v3使用php喜欢Youtube视频

Since Youtube Api V2 doesn't support like a specific video anymore. Can anyone please explain how to like a video with youtube api v3 ? I am always getting the following response:

 Response


400 Bad Request

- Show headers -

{
 "error": {
  "errors": [
   {
    "domain": "youtube.part",
    "reason": "unexpectedPart",
    "message": "contentDetails",
    "locationType": "parameter",
    "location": "part"
   }
  ],
  "code": 400,
  "message": "contentDetails"
 }
}

The request is :

Request


POST https://www.googleapis.com/youtube/v3/activities?part=snippet&key={YOUR_API_KEY}

Content-Type:  application/json
Authorization:  Bearer ya29.AHES6ZQUI8Gn7j93QZBmmdlDe7Ei-iqYseYAKAxyf3qTOHHwDHb-dA
X-JavaScript-User-Agent:  Google APIs Explorer

{
 "contentDetails": {
  "like": {
   "resourceId": {
    "videoId": "video-id",
    "kind": "youtube#video"
   }
  }
 }
}

The part is = snippet

I am following these docs : https://developers.google.com/youtube/v3/docs/activities/insert

  • 写回答

1条回答 默认 最新

  • doubei8541 2012-12-28 16:39
    关注

    The answer is already in the comments, but to elevate it a bit: YouTube API v3: Liking a video in Python has more information about liking a video, though the example there is in Python.

    The important part is that liking a video is done via a playlistItems.insert() call, not an activities.insert() call. This is a common source of confusion and I've already asked our tech writer to try to clear things up in the docs.

    评论

报告相同问题?