Youtube SimpleXMLElement问题

时间:2011-08-26 12:13:08

标签: php youtube simplexml

我正在使用php for youtube,但是出现在用户图片部分的xml文件没有出现在输出中。

代码:

$feedURL = 'http://gdata.youtube.com/feeds/api/users/davidguetta';
$sxml = simplexml_load_file($feedURL);

输出:

SimpleXMLElement Object
(
    [id] => http://gdata.youtube.com/feeds/api/users/davidguetta
    [published] => 2006-07-26T12:05:23.000-07:00
    [updated] => 2011-08-26T04:34:26.000-07:00
    [category] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [scheme] => http://schemas.google.com/g/2005#kind
                            [term] => http://gdata.youtube.com/schemas/2007#userProfile
                        )

                )

            [1] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [scheme] => http://gdata.youtube.com/schemas/2007/channeltypes.cat
                            [term] => Musician
                        )

                )

        )

    [title] => davidguetta Channel
    [link] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [rel] => http://gdata.youtube.com/schemas/2007#user.vlog
                            [type] => application/atom+xml
                            [href] => http://gdata.youtube.com/feeds/api/playlists/18F8D522B6C5D32C
                        )

                )

            [1] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [rel] => related
                            [type] => text/html
                            [href] => http://www.davidguetta.com
                        )

                )

            [2] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [rel] => alternate
                            [type] => text/html
                            [href] => http://www.youtube.com/profile?user=davidguetta
                        )

                )

            [3] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [rel] => self
                            [type] => application/atom+xml
                            [href] => http://gdata.youtube.com/feeds/api/users/davidguetta
                        )

                )

        )

    [author] => SimpleXMLElement Object
        (
            [name] => davidguetta
            [uri] => http://gdata.youtube.com/feeds/api/users/davidguetta
        )

)

为什么不输出以下内容?

<media:thumbnail url='http://i2.ytimg.com/i/uYZ-sFza5K_3GF0LyQAxjg/1.jpg'/>

1 个答案:

答案 0 :(得分:0)

看起来SimpleXMLElement在标签名称中被':'搞糊涂了。您可能应该使用YouTube PHP Data API代替。