2016-04-24 66 views
-1

您好朋友我想用屏幕php回顯(打印)屏幕上的YouTube視頻標識。如何使用php youtube數據api回顯所有視頻標識php

這是迄今爲止我的代碼。任何人都可以告訴我如何只顯示視頻ID沒有別的謝謝。

<?php 
$data = file_get_contents("https://www.googleapis.com/youtube/v3/search?maxResults=5&part=snippet&key=API_KEY"); 
$array = json_decode ($data,true); 
print_r ($array); 
+0

我已經發布的代碼的人。數組有像視頻標題desc的所有信息。等我只需要視頻ID – Jim

+1

所以你基本上什麼也沒試,並沒有發佈你有的數據。好的。您還發布了您的API密鑰,這是一個糟糕的主意。 – Chris

回答

0

我已經爲您調整了腳本,以便它將檢索視頻ID。

測試和工作片斷

<?php 
$apiKey = "enter-your-apikey-here"; 
$data = file_get_contents("https://www.googleapis.com/youtube/v3/search?maxResults=5&part=snippet&key=".$apiKey); 
$array = json_decode ($data,true); 
foreach($array['items'] as $data) { 
    var_dump($data['id']['videoId']); 
} 
+0

非常感謝,它正在按照我的要求工作:D – Jim

+0

您的歡迎兄弟! :d – swordsecurity

相關問題