YouTube SimpleXMLElement 问题!

发布于 2024-12-01 13:59:43 字数 3101 浏览 0 评论 0原文

我正在用 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'/>

i'm doing something with php for youtube but xml file that appear in the user picture section, does not appear in the output.

code:

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

output:

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
        )

)

why does not the output of the following?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

メ斷腸人バ 2024-12-08 13:59:43

看起来 SimpleXMLElement 被标签名称中的“:”混淆了。您可能应该改用 YouTube PHP 数据 API

It looks like the SimpleXMLElement is getting confused by ':' in tag names. You should probably be using the YouTube PHP Data API instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文