Jump to content

.json reading with php stucture


l3rodey

Recommended Posts

Hi guys, I am trying to play with reddit a little and redesign something ( personal use only ). I have this: 

$string_reddit = file_get_contents("http://reddit.com/.json");
$json = json_decode($string_reddit);  

$children = $json->data->children;

foreach ($children as $child){
echo $child->data->title;
}

This get's me all the listing titles of the home page, if you look at the .json file... 

BUT I now want to get the actually listing so for example... 

 

http://www.reddit.com/r/pics/comments/3anqj9/today_my_dad_finally_decided_to_cash_this_chip_in/

 

That is top of the list right now, if I put .json after it...

http://www.reddit.com/r/pics/comments/3anqj9/today_my_dad_finally_decided_to_cash_this_chip_in/.json 

 

You can see the file... 

 

My code doesn't work for that url though? If I replace the $string_reddit variable with that url it just errors out... What have I done wrong?

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/296946-json-reading-with-php-stucture/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.