Skip to content

Instantly share code, notes, and snippets.

@charliewilson
Created October 28, 2011 16:55
Show Gist options
  • Save charliewilson/1322759 to your computer and use it in GitHub Desktop.
Save charliewilson/1322759 to your computer and use it in GitHub Desktop.
kickpushlib - A PHP library for the KickPush JSON API
<?
//kickpushlib version 1.0.1
//A PHP library for the KickPush JSON API
//by Charlie Wilson
//Gets spot data from it's ID
function kp_SpotByID($id)
{
//Reads the response from the JSON API
$response = file_get_contents("http://www.kickpush.info/api/json_spot_byid.php?id=" . $id);
//Decodes the JSON to an array
$returnstring = json_decode($response, true);
//Returns the data
return $returnstring;
}
//Gets spot data from it's name
function kp_SpotByName($name)
{
//Reads the response from the JSON API, encoding spaces in the name
$response = file_get_contents("http://www.kickpush.info/api/json_spot_byname.php?id=" . urlencode($name));
//Decodes the JSON to an array
$returnstring = json_decode($response, true);
//Returns the data
return $returnstring;
}
//Gets user data from their username
function kp_UserByUsername($username)
{
//Reads the response from the JSON API, encoding the username for non-standard characters
$response = file_get_contents("http://www.kickpush.info/api/json_user_byusername.php?id=" . urlencode($username));
//Decodes the JSON to an array
$returnstring = json_decode($response, true);
//Returns the data
return $returnstring;
}
//Gets user data from their full name
function kp_UserByFullname($fullname)
{
//Reads the response from the JSON API, encoding spaces in the name
$response = file_get_contents("http://www.kickpush.info/api/json_user_byfullname.php?id=" . urlencode($fullname));
//Decodes the JSON to an array
$returnstring = json_decode($response, true);
//Returns the data
return $returnstring;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment