when decoding this json file 'https://2geekproar.blogspot.com/feeds/posts/default?alt=json&callback=showpostcount' , Nothing appears to me and i want o get $totalResults":{"$t":"4"} which equals '4' i want to decode this json file and get this value
my code
<?php
$url = 'https://2geekproar.blogspot.com/feeds/posts/default?alt=json&callback=showpostcount' ;
$json = file_get_contents($url);
// Decode the JSON file
$json_data = json_decode($json,true);
// Display data
print_r($json_data);
?>
When you add echo json_last_error_msg();
to your script, you will see that you get the following error message:
Syntax error
That indicates to you, that the string you are trying to decode is not a valid JSON string.
Because of that, you are getting no output.
var_dump($json_data); // Returns NULL
So, because the string you are parsing is not well formatted, you have to check that out, viewing the URL shows:
// API callback
showpostcount({"version":"1.0","encoding":"UTF-8","feed":
// …
Which indeed is not a plain JSON object.
As pointed out in the comments under your question, you can fix that, by removing &callback=showpostcount
from your request URL.
https://2geekproar.blogspot.com/feeds/posts/default?alt=json
Will give you only your valid JSON object, which you can parse without problems:
{"version":"1.0","encoding":"UTF-8","feed":…
Decodes to:
array(3) {
["version"]=>
string(3) "1.0"
["encoding"]=>
string(5) "UTF-8"
["feed"]=>
array(18) {
["xmlns"]=> …
How we can insert header and footer in google docs with google docs api using PHP code
Writing a new and appending a file in PHP without erasing contents
How to combine 2 arrays with the condition that 2 and 5 values will be from the second array?
How to keep the ?error on url if page extension not included?
I'm building a login systemMy database looks like this Lets say, after loggin in, the code recognizes who is currently logged in and sends them to a specific website, based on the content in their KURS field
I'm currently writing a chat program in PHP and AJAX and have PHPMailer installed and in use
I'm attempting to convert a piece of PHP code to dart and I came across a few things I've simply never used before, one of which is a single pipe |Im not sure what the exact dart equivalent is, if there even is one
I'm trying to convert a piece of PHP code to dart and getting stuckWhat I have is a PHP array text that gets run through a function called toUTF8 as follows: