Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php API提要没有';不要给我现场的数据_Php_Youtube_Youtube Api - Fatal编程技术网

Php API提要没有';不要给我现场的数据

Php API提要没有';不要给我现场的数据,php,youtube,youtube-api,Php,Youtube,Youtube Api,所以我对YouTube API提要有一个问题 在我们的live网站上,它并没有打印提要的数据,但当我转到开发人员服务器时,所有内容都正确打印 以下是一个基本测试页面作为示例: 我什么也没看见 以下是我应该看到的片段: SimpleXMLElement Object ( [id] => tag:youtube.com,2008:video:wzE9T5iy00Y [published] => 2013-03-25T19:13:32.000Z [updated]

所以我对YouTube API提要有一个问题

在我们的live网站上,它并没有打印提要的数据,但当我转到开发人员服务器时,所有内容都正确打印

以下是一个基本测试页面作为示例:

我什么也没看见

以下是我应该看到的片段:

SimpleXMLElement Object
(
    [id] => tag:youtube.com,2008:video:wzE9T5iy00Y
    [published] => 2013-03-25T19:13:32.000Z
    [updated] => 2013-06-05T13:29:37.000Z
    [category] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [scheme] => http://schemas.google.com/g/2005#kind
                            [term] => http://gdata.youtube.com/schemas/2007#video
                        )

                )

            [1] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [scheme] => http://gdata.youtube.com/schemas/2007/categories.cat
                            [term] => Autos
                            [label] => Autos & Vehicles
                        )

                )

        )

    [title] => GPS Tracker Used by Action Lock and Safe
    [content] => SimpleXMLElement Object
        (
            [@attributes] => Array
                (
                    [type] => application/x-shockwave-flash
                    [src] => https://www.youtube.com/v/wzE9T5iy00Y?version=3&f=videos&app=youtube_gdata
                )

        )
下面是我在test.php页面上使用的代码:

<?php
    $entryURL = 'https://gdata.youtube.com/feeds/api/videos/wzE9T5iy00Y?v=2';
    $feed = simplexml_load_file($entryURL);
?>

<pre><?php print_r($feed); ?></pre>

这个基本的例子只使用“视频”提要,但我对所有提要都有相同的问题

现在这些提要在周五正常工作,所以从那时到现在发生了一些事情

我已经排除了这可能是编程错误的可能性,因为在我提供的示例中,我去掉了所有内容,只留下了最小值。另外,同样的代码在dev服务器上也非常有效

我不认为这是YouTube API,因为我没有看到任何重大公告,我看到的其他订阅源工作正常

因此,这让我相信这是我的网站或我的帐户的问题。我得到的印象是,这与我的帐户有关,因为我的网站上使用其他应用程序的其他提要工作正常

我如何解决这个问题,或者进一步排除故障以便解决它?

这听起来(看起来)很可疑,好像您的生产服务器上的php标志
allow\u url\u fopen
已经关闭。如果您有权访问php.ini文件,可以检查该标志(需要打开该标志才能允许simplexml_load_file加载远程数据)。如果是托管环境,您没有访问权限,可以编写如下例程进行检查:

function curl_get_contents ($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $output = curl_exec($ch);
    curl_close($ch);
    return $output;
}

$entryURL = 'https://gdata.youtube.com/feeds/api/videos/wzE9T5iy00Y?v=2';
$feed = simplexml_load_file(curl_get_contents($entryURL));
如果这是问题所在,而您没有权限重新打开它,则可以使用curl:

如果这不是问题所在,请检查您的日志,查看simplexml加载文件是否抛出任何错误。

这听起来(看起来)很可疑,好像生产服务器上的php标志
allow\u url\u fopen
已经关闭。如果您有权访问php.ini文件,可以检查该标志(需要打开该标志才能允许simplexml_load_file加载远程数据)。如果是托管环境,您没有访问权限,可以编写如下例程进行检查:

function curl_get_contents ($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $output = curl_exec($ch);
    curl_close($ch);
    return $output;
}

$entryURL = 'https://gdata.youtube.com/feeds/api/videos/wzE9T5iy00Y?v=2';
$feed = simplexml_load_file(curl_get_contents($entryURL));
如果这是问题所在,而您没有权限重新打开它,则可以使用curl:


如果这不是问题,请检查您的日志,查看simplexml加载文件是否抛出任何错误。

感谢您的回复!我刚刚测试了你的if语句,我们的dev服务器的allow_url_fopen是“开”的,而我们的live站点的allow_url_fopen是“关”的。所以这看起来很有希望。在研究curl之前,我会联系我的托管服务,看看能做些什么。我会通知你的。再次感谢!谢谢你的回复!我刚刚测试了你的if语句,我们的dev服务器的allow_url_fopen是“开”的,而我们的live站点的allow_url_fopen是“关”的。所以这看起来很有希望。在研究curl之前,我会联系我的托管服务,看看能做些什么。我会通知你的。再次感谢!