我有正確檢索,使用YouTube api,標題,視頻網址,viewcount,視頻日期,最新評論日期和前160個字符的PHP代碼描述。我似乎無法弄清楚如何得到整個描述。我知道它在檢索到的XML中,因爲我已經拋棄了它。那麼我怎麼才能得到160個字符?如何獲得整個YouTube視頻說明,php,gdata
整個描述被截斷爲157個字符,並添加「...」,以便在我回顯它或var_dump時,它是160個字符。這是我的完整測試代碼(沒有標題,視頻網址等)。
<?php
$feedURL = 'http://gdata.youtube.com/feeds/api/videos?q=phone&v=2&fields=entry[yt:statistics/@viewCount > 10000]&start-index=1&max-results=1';
$sxml = simplexml_load_file($feedURL);
foreach ($sxml->entry as $entry) {
$media = $entry->children('http://search.yahoo.com/mrss/');
echo $media->group->description;
}
?>
這是在頁面上顯示的內容:
免費TuTiTu的遊戲:在http://www.tutitu.tv/index.php/games免費TuTiTu的着色頁:http://www.tutitu.tv/index.php/coloring加入我們的Facebook:HTTPS ...
當我得到的XML的方法:
gdata.youtube.com/feeds/api/videos/JI-5kh_4gO0?v=2 & ALT = JSON-在腳本&回調= youtubeFeedCallback & prettyprint = TR UE
完整的描述是這樣的:
"media$description": {
"$t": "FREE TuTiTu's Games: http://www.tutitu.tv/index.php/games\nFREE TuTiTu's Coloring pages at: http://www.tutitu.tv/index.php/coloring\nJoin us on Facebook: https://www.facebook.com/TuTiTuTV\nTuTiTu's T-Shirts: http://www.zazzle.com/TuTiTu?rf=238778092083495163\n\nTuTiTu - The toys come to life\n\nTuTiTu - \"The toys come to life\" is a 3D animated television show targeting 2-3 year olds. Through colorful shapes TuTiTu will stimulate the children's imagination and creativity. On each episode TuTiTu's shapes will transform into a new and exciting toy.",
"type": "plain"
},
我敢肯定,我缺少一些基本的東西,但是當我看了一個解決方案,我還沒有發現它。
感謝您的任何幫助。
謝謝,尼姑,這是我需要的。我想在描述長度上的差異可能在某個地方被記錄下來,但是很好的悲傷,發現它是相當麻煩的。 – Amber 2013-04-23 19:16:09
給出的答案不適用於版本3.使用像這樣 - > 'https://www.googleapis.com/youtube/v3/videos?key=&part = snippet&id = –
Manibharathi
2015-06-29 11:31:21