[英]simplexml_load_file() error
我使用PHP相对较新,使用XML更是如此。
我有一个脚本在我的本地主机上完美运行,但当我尝试将它放在我的服务器上时,我收到此消息:
警告:simplexml_load_file()[function.simplexml-load-file]: http ://api.wefeelfine.org:8080 / ShowFeelings?display = xml&feeling = happy&againfields = imageid,feeling,sentence,postttime,posttdate,postturl,gender,country ,州,城市,纬度,经度和限制= 0&extraimages = 20:1 :
解析器错误:第21行的/home2/alsweet/public_html/notalone.php中的文档为空
不起作用的代码行是这样的:
// get api feed
$xml = simplexml_load_file('http://api.wefeelfine.org:8080/ShowFeelings?display=xml&feeling=' . $feeling . '&returnfields=imageid,feeling,sentence,posttime,postdate,posturl,gender,country,state,city,lat,lon&limit=0&extraimages=20');
我弄错了吗? 我应该和我的托管服务提供商说话吗?
使用你的xml加载器中的url我得到:
<?xml version="1.0"?>
<feelings>
</feelings>
所以应该解析好。 请咨询您的托管服务提供商,以确保支持simplexml_load_file。
尝试隔离该行,看看它确实是问题来自哪里。 在自己的文件中运行此代码,看看是否有效。
<?php
$xml = simplexml_load_file('http://api.wefeelfine.org:8080/ShowFeelings?display=xml&feeling=happy&returnfields=imageid,feeling,sentence,posttime,postdate,posturl,gender,country,state,city,lat,lon&limit=0&extraimages=20');
print_r($xml);
?>
这对我的托管来说实际上是一个问题,
事实证明,这是因为我试图呼叫端口8080上的另一台服务器,该端口未在防火墙中打开。 所以他们打开它,它工作正常。
非常感谢您的帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.