Find a Forrst User:


Enter Username:
'; if(!$_POST['username']){ $u = forrst_user('crassiusneo'); echo '
Hi, My name is '.$u['name'].' and I hope you liked my tutorial on how to user the Forrst API.

You can check out my Forrst profile at '.$u['url'].'.
You can recognize me by my icon My cool little icon!
'; }else{ $u = forrst_user($_POST['username']); if(isset($u['error']) || $u==''){ if($u=='') $data['error']='Not Found.'; echo '

Your request for data about username: '.$_POST['username'].' failed. Reason: '.$data['error'].'

'; }else{ echo '

The user with username:'.$u['username'].' on Forrst is '.$u['name'].'.

They Created '.$u['posts'].' Posts,
Made '.$u['comments'].' Comments,
Liked '.$u['likes'].' Posts by other users,
Have '.$u['followers'].' Followers,
and Follow '.$u['following'].' other users.

You can check out their Forrst profile at '.$u['url'].'.
You can recognize them by their icon Their cool little icon!

'; } } echo '
'; function forrst_user($username){ $userdata = file_get_contents("http://api.forrst.com/api/v2/users/info?username=".$username); // We use json_decode to put the data into an array. //Note: json_decode only work in PHP5.2+ and the module must be installed in apache on your server. $data = json_decode($userdata, true); //print_r($data); $user = $data['resp']; /* $user now contains the following information: $user['id'] : The Forrst ID # $user['username'] : The Username. $user['name'] : The Name. $user['url'] : The Profile URL for the User. $user['posts'] : The # of Posts Created by the User on Forrst. $user['comments'] : The # of Comments made by the User on Forrst Posts. $user['likes'] : The # of Likes made by the User on Forrst Posts. $user['followers'] : The # of people following this User. $user['following'] : The # of people followed by this User. $user['photos'] : Array of all the images stored for this user on Forrst. [xl_url] (200px by 200px) [large_url] (150px by 150px) [medium_url] (75px by 75px) [small_url] (45px by 45px) [thumb_url] (25px by 25px) $user['in_directory'] : 1 meaning the user is in the forrst directory and 0 if they are not. $user['tag_string'] : comma delimited string of tags the user finds themselves interested in. At the time of this writing there are additional fields being returned that may later on be used for proper authentication as there is currently no authentication to pull this data. These fields are: $data['stat'] : Returns the status of the response. "ok" if the request succeeded. "fail" in case of an error. $data['in'] : Returns the time it took to execute the request in seconds. $data['authed'] : Currently returns empty or "false". This field tells us if the request was authorized. $data['authed_as'] : Currently returns empty or "false". This field will most likely tell us in the future which API user made the request. $data['env'] : Currently just returns "prod" (As in Production Environment) This fields is probably more useful to the Forrst Devs than to us. In case of failure: $data['error'] : Contains the textual Error Message returned by the API */ if($data['stat']=='ok') return $user; else{ if($data['stat']=='fail'){ return array('error'=>$data['error']); }else{ //There could be additional statuses returned in the future } } } ?>