Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save davidvthecoder/3995142 to your computer and use it in GitHub Desktop.

Select an option

Save davidvthecoder/3995142 to your computer and use it in GitHub Desktop.
Happpi PHP Library Examples - Examples on how to use the CURT PHP Library known as Happpi.
<?php
require_once('libraries/happpi/LoadAll.php'); // points to the LoadAll.php file for loading the library.
// once the library is required, you can now use one of the main "interaction" classes.
// These interaction classes contain methods that get information from our REST API and
// converts them to PHP objects for you to use.
$category = new CurtCategory(); // create new category object to use category's functions.
$MainCategories = $category->getParentCategories(); // call getParentCategories which returns a list of categories.
echo "<h2>Main Categories</h2>";
foreach($MainCategories as $category){ // step through the list of categories
echo $category->getCatTitle(); // print the title of each category.
echo "<br />";
}
?>
<?php
require_once('libraries/happpi/LoadAll.php'); // points to the LoadAll.php file for loading the library.
?>
<!doctype html>
<html>
<head>
</head>
<body>
<h1>Your PHP Website.</h1>
<?php
// once the library is required, you can now use one of the main "interaction" classes.
// These interaction classes contain methods that get information from our REST API and
// converts them to PHP objects for you to use.
$category = new CurtCategory(); // create new category object to use category's functions.
$MainCategories = $category->getParentCategories(); // call getParentCategories which returns a list of categories.
echo "<h2>Main Categories</h2>";
foreach($MainCategories as $category){ // step through the list of categories
echo $category->getCatTitle(); // print the title of each category.
echo "<br />";
}
?>
</body>
</html>
<?php
require_once('libraries/happpi/LoadAll.php'); // points to the LoadAll.php file for loading the library.
// once the library is required, you can now use one of the main "interaction" classes.
// These interaction classes contain methods that get information from our REST API and
// converts them to PHP objects for you to use.
$vehicle = new CurtVehicle(); // create new vehicle object to gain access to its functions.
$vehicle->setMount("rear"); // set optional "dependency" of mount.
$years = $vehicle->getYears(); // call getYears which returns an array of type float (for half years).
echo "<h2>The list of years that has rear mounts</h2>";
foreach($years as $year){ // step through the list of categories
echo $year;
echo "<br />";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment