[英]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.