2013-12-18 33 views
0

我,用file_get_contents得到JSON格式的file_get_contents返回空的結果

$queryurl = "http://cloud.softpanda.com.au:9874/loyalty/customer/query-account?user=foo&pass=bar&format=json"; 
$queryurl = $queryurl . "&number=" . urlencode($cardnumber); 
$queryurl = $queryurl . "&pin=" . urlencode($cardpin); 

$queryresult = @file_get_contents($queryurl); 
$jsonresult = @json_decode($queryresult, true); 

的問題是,結果顯示,當我手動去到URL的輸出,但是當我打印$queryresult我什麼也沒得到。它顯示了一個空的結果。當在我的本地服務器上使用它時,它工作正常,但是當我在實時(遠程)服務器上使用它時,我遇到了這個問題。

+1

如果您刪除了「@」這個可怕的操作符,您會發現錯誤。 – h2ooooooo

+0

也許你應該使用'file_get_contents'而不是'file_put_contents'? – brezanac

+0

刪除@操作符後出現此錯誤: - Warning:file_get_contents(http://cloud.softpanda.com.au:9874/loyalty/customer/query-account?user=ivapine-web&pass=GqJcSPNblD&format=json&number=YY&pin=AA )[函數。文件獲取內容]:無法打開流:連接被拒絕在/home/content/63/11277163/html/melissa/loyalty/myaccount.php 64行 – Rohit

回答

0

你需要讓

allow_url_fopen 

在php.ini配置文件。出於安全原因,它常常在實時服務器上禁用。您可以通過執行phpinfo()檢查來檢查它是否被禁用。

+0

是的,它已經開啓 – Rohit