Cách sử dụng Data youtube api v3

Các hàm dùng để login youtube qua api

$client = new Google_Client();
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri($redirect_uri);
 $client->setScopes(array(
"https://www.googleapis.com/auth/plus.login",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/plus.me",
"https://www.googleapis.com/auth/youtube.upload",
"https://www.googleapis.com/auth/youtube",
"https://www.googleapis.com/auth/youtube.force-ssl"
));

$plus = new Google_Service_Plus($client);
$youtube = new Google_Service_YouTube($client);

Trước khi sử dụng chúng ta cần tạo API KEY từ trang https://console.developers.google.com

Vào youtube xem phần cách tạo API KEY https://www.youtube.com/watch?v=Sg9CyjNpFoU

Sau khi tạo API KEY trong dự án -> ta cần enable các thư viện như sau:

Link get comment từ 1 video

https://youtube.googleapis.com/youtube/v3/commentThreads?part=id%2Csnippet&videoId=oTH-7Lqw5JY&maxResults=100&key=…

Link comment demo https://developers.google.com/youtube/v3/docs/commentThreads/list?apix=true&apix_params=%7B%22part%22%3A%5B%22id%2Csnippet%22%5D%2C%22maxResults%22%3A100%2C%22pageToken%22%3A%22QURTSl9pMGM1WlNDWmdSdkVlcHJSVTBLaWhyVUVMYkN1d3I3TTIwcUE1UnFCY3JiX2oyb2h0Z251czlkWVZIbWJVN0o1Y2lmNTJjcUdwUV9jdzZOVjlBU1l2T0VqTGxjN1E%3D%22%2C%22videoId%22%3A%22oTH-7Lqw5JY%22%7D

 

Link detail video https://developers.google.com/youtube/v3/docs/videos/list?apix_params=%7B%22part%22%3A%5B%22snippet%2CcontentDetails%2Cstatistics%22%5D%2C%22id%22%3A%5B%22oTH-7Lqw5JY%22%5D%7D

Cần dùng dữ liệu khi login thì kích hoạt google+ API, cần dùng dữ liệu từ youtube thì kích hoạt Youtube data api V3