l3rodey Posted June 22, 2015 Share Posted June 22, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/296946-json-reading-with-php-stucture/ Share on other sites More sharing options...
requinix Posted June 22, 2015 Share Posted June 22, 2015 You can't just stick a ".json" at the end and assume it will work. API documentation Quote Link to comment https://forums.phpfreaks.com/topic/296946-json-reading-with-php-stucture/#findComment-1514543 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.