简单的 PHP 和JSON
我在这个脚本上遇到了麻烦。它可以在我的本地服务器和测试服务器上运行,但在我的 Rackspace 服务器上似乎无法正常运行。
<?php
$path = "http://query.yahooapis.com/v1/public/yql?q=";
$path .= urlencode("SELECT * FROM feed WHERE url='http://feeds.feedburner.com/TMSEvents'");
$path .= "&format=json";
$feed = file_get_contents($path, true);
$feed = json_decode($feed); ?>
这很简单,但我在 Rackspace 服务器上收到以下错误消息:
PHP 警告: file_get_contents(http://query.yahooapis.com/v1/public/yql?q=SELECT+%2A+FROM+feed+WHERE+url%3D%27http%3A%2F%2Ffeeds.feedburner.com%2FTMSEvents%27&格式=json) [函数.文件获取内容]: 打开流失败:HTTP 请求失败! HTTP/1.0 500 999 本页 目前不可用
任何人都知道为什么这可以在一台服务器上运行,但不能在另一台服务器上运行?谢谢!
I'm having trouble with this script. It works on my local server and test server, but doesn't seem to run correctly on my Rackspace server.
<?php
$path = "http://query.yahooapis.com/v1/public/yql?q=";
$path .= urlencode("SELECT * FROM feed WHERE url='http://feeds.feedburner.com/TMSEvents'");
$path .= "&format=json";
$feed = file_get_contents($path, true);
$feed = json_decode($feed); ?>
It is very simple, but I am getting the follow error message on the Rackspace server:
PHP Warning:
file_get_contents(http://query.yahooapis.com/v1/public/yql?q=SELECT+%2A+FROM+feed+WHERE+url%3D%27http%3A%2F%2Ffeeds.feedburner.com%2FTMSEvents%27&format=json)
[function.file-get-contents]:
failed to open stream: HTTP request failed! HTTP/1.0 500 999 This page
is currently unavailable
Anyone have any ideas why this would work on one server, but not on another? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看这个: http://codular.com/curl-with-php
尝试下面的代码。经过测试,其工作正常:
Look on this : http://codular.com/curl-with-php
Try Below code. Its working fine with tested :