-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathquery.php
58 lines (43 loc) · 1.21 KB
/
query.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
$data = array(
"apikey" => "y9CJUD8A",
"objectType" => "animals",
"objectAction" => "publicSearch",
"search" => array (
"resultStart" => 0,
"resultLimit" => 100,
"resultSort" => "animalID",
"resultOrder" => "asc",
"calcFoundRows" => "Yes",
"filters" => array(
array(
"fieldName" => "animalSpecies",
"operation" => "equals",
"criteria" => "cat",
),
),
"fields" => array("animalID","animalOrgID","animalName","animalBreed")
),
);
// behavior & images
$jsonData = json_encode($data);
/// create a new cURL resource
$ch = curl_init();
// set options, url, etc.
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
curl_setopt($ch, CURLOPT_URL, "https://api.rescuegroups.org/http/v2.json");
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_POST, 1);
//curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
if (curl_errno($ch)) {
$results = curl_error($ch);
} else {
// close cURL resource, and free up system resources
curl_close($ch);
$results = $result;
}
$resultsArray = json_decode($results);
print_r($results);
?>