3

YouTube API、タイトル、ビデオの URL、ビューカウント、ビデオの日付、最後のコメントの日付、および説明の最初の 160 文字を使用して正しく取得する php コードがあります。説明全体を取得する方法がわかりません。私はそれをダンプしたので、取得したxmlにあることを知っています。では、どうして 160 文字しか得られないのでしょうか。

説明全体が 157 文字で切り捨てられ、「...」が追加されるため、echo または var_dump するまでに 160 文字になります。これが私の完全なテストコードです(タイトル、ビデオのURLなどはありません)。

<?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-in-script&callback=youtubeFeedCallback&prettyprint=true

説明全体は次のようになります。

"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"
},

基本的なものが欠けていると確信していますが、解決策を探しても見つかりませんでした。

助けてくれてありがとう。

4

2 に答える 2

1

$media->group->{'media$description'}トリックを行う必要があります

于 2013-04-22T22:08:08.180 に答える