Reputation: 151
Does Php have a method that calls a Json URL, and save in a variable the data it fetches for example can I used: "https://www.googleapis.com/blogger/v3/blogs/1/posts/"
I been trying with this code, but i am not sure if this is wrking
curl_setopt($ch, CURLOPT_URL, "https://www.googleapis.com/blogger/v3/blogs/1/posts/");
curl_setopt($ch, CURLOPT_HEADER, 0);
$df = curl_exec($ch);
curl_close($ch);
Upvotes: 0
Views: 85
Reputation: 187
You can use the bulti-in function json_decode http://php.net/manual/it/function.json-decode.php
$json = file_get_contents("https://www.googleapis.com/blogger/v3/blogs/1/posts/");
$obj = json_decode($json); //returns an object of json values
$array = json_decode($json, true); //returns an array of json values
Upvotes: 4
Reputation: 1732
The problem is http*s*, try adding these:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
Upvotes: 4