Permalink
Browse files

Cleaning up some doc package statements, cleaning the example script up

  • Loading branch information...
1 parent a447eef commit f5046749826bbeacba0ca2736e2cc0e7038ba81c Zachary Parmley committed Aug 2, 2012
Showing with 25 additions and 32 deletions.
  1. +2 −2 API/Request.php
  2. +2 −2 API/URL.php
  3. +2 −2 Exception.php
  4. +1 −1 Pet.php
  5. +18 −25 example.php
View
@@ -5,9 +5,9 @@
use Petfound\Pet;
/**
- * Request
+ * Petfound\API\Request Takes a url and requests data from the petfinder api, the parses into a more usable data type
*
- * @package PetfinderAPI
+ * @package Petfound\API
* @author Zachary Parmley
**/
class Request {
View
@@ -3,9 +3,9 @@
use Petfound\Exception as PetfoundException;
/**
- * ZP_Petfinder_URL
+ * Petfound\API\URL
*
- * @package Petfound
+ * @package Petfound\API
* @author Zachary Parmley
**/
class URL {
View
@@ -1,9 +1,9 @@
<?php
namespace Petfound;
/**
- * Exception raised by Petfound library
+ * Petfound\Exception
*
- * @package PetfinderAPI
+ * @package Petfound
* @author Zachary Parmley
**/
class Exception extends \Exception {}
View
@@ -2,7 +2,7 @@
namespace Petfound;
/**
- * Pet represents a pet returned from the API parsed into a more useable format
+ * Petfound\Pet represents a pet returned from the API parsed into a more useable format
*
* @package Petfound
* @author Zachary Parmley
View
@@ -1,49 +1,40 @@
<?php
-namespace Petfound;
-
use Petfound\Exception as PetfoundException;
use Petfound\API\URL;
use Petfound\API\Request;
-$motd = <<<MOD
+echo <<<MOTD
=======================
-EXAMPLE SCRIPT INVOKING PETFINDER API CODE SAMPLES
+EXAMPLE SCRIPT INVOKING "PETFOUND" PETFINDER API LIBRARY
BY: Zachary Parmley
-This script just invokes the associated PetfinderAPI classes
-and uses them to display a list of dogs from a dachsund rescue
-organization I work with.
+This script just invokes the associated API classes
+and uses them to display a list of dogs from a shelter
+on petfinder.
-The script is intended to be run with at least PHP 5.3
+You'll have to configure the SHELTER ID, API KEY and API SECRET.
-The interesting/OO code is in the classes themselves.
-=======================
+The library requires at least PHP 5.3, tested on 5.3.13
-MOD;
-// echo $motd;
-// function __autoload($classname) {
-// var_dump($classname);die();
-// $classfile = substr($classname, strrpos($classname, '_') + 1) . '.php';
-// require_once($classfile);
-// }
+=======================
+MOTD;
spl_autoload_register(function($class) {
require(implode('/', array_slice(explode('\\', $class), 1)) . '.php');
});
-
try {
echo "\nSearching petfinder for dogs...";
$requestType = 'shelter.getPets';
$requestArgs = array(
- 'id' => 'SHELTER ID HERE',
+ 'id' => 'SHELTER ID',
'status' => 'A',
'count' => 10,
'format' => 'json');
- $key = 'API KEY HERE';
- $secret = 'API SECRET HERE';
+ $key = 'API KEY';
+ $secret = 'API SECRET';
$url = new URL($requestType, $requestArgs, $key, $secret);
$result = new Request();
$result->setUrl($url);
@@ -59,11 +50,13 @@
echo "\n\n";
} catch (PetfoundException $ex) {
- echo "There seems to have been a problem with the way this example was set up. That, or the Petfinder API is down. Darn.\n\nError message:\n\t";
- echo $ex->getMessage();
+ echo 'There seems to have been a problem with the way this example was set up. That, or the Petfinder '
+ . "API is down. Darn.\n\nError message:\n\t"
+ . $ex->getMessage();
} catch (\Exception $ex) {
echo 'There was a PHP Exception thrown during execution of the example. It was intended to be run on '
. 'PHP 5.3 and should work with just the default modules. For whatever reason, it did not work this '
- . "time...\n\nError message:\n\t";
- echo "\n" . $ex->getMessage();
+ . "time...\n\nError message:\n\t"
+ . $ex->getMessage()
+ . "\n";
}

0 comments on commit f504674

Please sign in to comment.