2016-02-29 80 views
2

一個JSON服務這是下面的代碼,我使用如何獲得在PHP

$角色僅僅是window.jQuery一個快捷方式。

<?php 
$contents= file_get_contents('http://skillpage.enigmateleco.net/rest/[email protected]&pass=12345'); 
     $contents = utf8_encode($contents); 
     $contents_array = json_decode($contents,1); 
?> 

代碼表示錯誤

警告:的file_get_contents(http://[email protected]&pass=12345):未能 打開流:HTTP請求失敗! HTTP/1.1 403 ModSecurity的動作在 C:\ XAMPP \ htdocs中\ skillbook \ json1.php第9行

+2

我認爲這只是意味着你的服務器(-provider)阻止來自PHP的跨域請求。 –

+0

我強烈建議你使用CURL而不是file_get_contents –

+1

這個鏈接的預期輸出是什麼? –

回答

-1

嘗試使用此:$數據= json_decode($請求,TRUE);這項工作只有當你的請求是在JSON格式