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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.