Hate My Blog

Fuzzy status of who’s online at reddit

This is some quick and dirty little code to test without much precision if any particular user is online over at Reddit.

$url='http://www.reddit.com/user/HattoriHanzo.json';

//get the url | json decode it to an array
$j=json_decode(file_get_contents($url),1);
//this just grabs the first element and then its timestamp
$t=$j[data][children][0][data][created_utc];

//this is a delay of 15 min. use std. timestamp math
if((time()-$t) < (60 * 15)){
	//and they are online ;)
}

//or offline ;(
About these ads

September 10, 2009 - Posted by | Code, PHP | , , , ,

1 Comment »

  1. This code is pig disgusting.

    * Whitespace,please.Peopledon’twritelikethis.
    * Using undefined constants as strings relies on non-standard behavior and should be throwing warnings.
    * It’s in PHP.

    Comment by Anonymous | September 10, 2009 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: