Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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

Authenticating
<?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);
?>
  • No labels