Versions Compared

Key

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

Be sure to set your public apikey and also the value for animalOrgID.

It's possible to dynamically update data and information on websites using publicly accessible data via the HTTP API.

...

To do this via the RescueGroups.org Website service, you'll need both a Custom Code Snippet, and a web page with some HTML included.

Custom Code Snippet

Create a Custom Code Snippet and include the following JavaScript code:

Code Block
languagejavascript
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
<script src="https://s3.amazonaws.com/filestore.rescuegroups.org/scripts/noncvs/jquery-json.js" type="text/javascript"></script>

<script>
var thing = {"apikey":"****","objectType":"animals","objectAction":"publicSearch","search":{"calcFoundRows":"Yes","resultStart":0,"resultLimit":0,"fields":["animalName"],"filters":[{"fieldName":"animalStatus","operation":"equals","criteria":"Adopted"},{"fieldName":"animalOrgID","operation":"equals","criteria":"****"}]}};
var encoded = $.toJSON(thing)

$.ajax({
  url: "https://api.rescuegroups.org/http/json/?data=" + encoded,  
  dataType: "jsonp",
  success: function(data) {
        if (data.foundRows) document.getElementById('adoptedPetsCount').innerHTML = data.foundRows;
  },
  error: function(xhr, status, error) {
    console.log('error');
  }
});  
</script>
Info

Be sure to enter replace the asterisks in the example above with your public API Key for the apikey value and your account number for the animalOrgID value.

Add content to the web page

Edit the web page or content area where you would like the dynamic data to appear.  You'll need to do two things:

...