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
我什麼也沒得到。它顯示了一個空的結果。當在我的本地服務器上使用它時,它工作正常,但是當我在實時(遠程)服務器上使用它時,我遇到了這個問題。
如果您刪除了「@」這個可怕的操作符,您會發現錯誤。 – h2ooooooo
也許你應該使用'file_get_contents'而不是'file_put_contents'? – brezanac
刪除@操作符後出現此錯誤: - 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