Versions Compared

Key

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

...

Code Block
languagephp
titleAuthenticating + list of animals with no filters.
<?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);
?>

...