2013-12-17 59 views
0

我仍然想知道如何從此鏈接https://developers.google.com/blogger/docs/3.0/using的REST Api請求獲取json對象。從REST Blogger Api請求與PHP檢索JSON對象

它說GET https://www.googleapis.com/blogger/v3/blogs/2399953?key=YOUR-API-KEY請求將提供有關特定博客的信息。

我也是PHP noobs。這是我的代碼。

<?php 
$blogID = 'xxx'; 
$apikey = 'yyy'; 

$requestURL = "https://www.googleapis.com/blogger/v3/blogs/{$blogID}?key={$apikey}"; 

$json = file_get_contents($requestURL); 
print_r($json); 

?> 

我對此不知情,所以請幫助我找到問題所在。在此先感謝

回答

0

試試這個:

$json = json_decode(file_get_contents($requestURL)); 

你取一個JSON串並試圖print_r它,這僅適用於數組。

json_decode顧名思義,解碼JSON字符串並將其轉換爲數組/對象。