I'm still wondering how to get json object from REST Api request from this link https://developers.google.com/blogger/docs/3.0/using .
It says GET https://www.googleapis.com/blogger/v3/blogs/2399953?key=YOUR-API-KEY
request will give informations about particular blog.
I'm also PHP noobs. Here's my code.
<?php
$blogID = 'xxx';
$apikey = 'yyy';
$requestURL = "https://www.googleapis.com/blogger/v3/blogs/{$blogID}?key={$apikey}";
$json = file_get_contents($requestURL);
print_r($json);
?>
I have no idea about this, so please help me to find where the problem is. Thanks in advance
Try this:
$json = json_decode(file_get_contents($requestURL));
You are fetching a JSON
string and trying to print_r
it, which only works on arrays.
json_decode
, as its name implies, decodes the JSON string and transforms it into an array / object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.