Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Below are some code examples to help you get started with using our API.  All sample code and information are provided "as is" without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

PHP

Code Block
languagephp
titleAuthenticating
<?php
$headers = array("content-type:application/json");
$shelterbuddyUrl = "https://mysite.shelterbuddy.com";
$username = urlencode("my@username");
$password = urlencode("myS3ecureP@ssw@rd");

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
curl_setopt($ch, CURLOPT_URL, $shelterbuddyUrl . sprintf("/api/v2/authenticate?username=%s&password=%s", $username, $password)); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch); 

$authToken = json_decode($result); 
array_push($headers, sprintf("sb-auth-token:%s", $authToken));

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
curl_setopt($ch, CURLOPT_URL, $shelterbuddyUrl . sprintf("/api/v2/animal/list?PageSize=%s", 1)); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, "{ }");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($ch); 
$result = json_decode($result);
var_dump($result);
?>

...