From 2f319fd61a257d000ed16c5e08d501164a74ba27 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 19 Feb 2016 14:47:39 -0500 Subject: [PATCH 1/2] Adds optional OData Query capabilities Adds optional OData Query capabilities to the call() function --- actionnetwork.class.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/actionnetwork.class.php b/actionnetwork.class.php index c9a2d4a..3dd57d2 100644 --- a/actionnetwork.class.php +++ b/actionnetwork.class.php @@ -17,7 +17,7 @@ public function __construct($api_key = null) { $this->api_key = $api_key; } - public function call($endpoint, $method = 'GET', $object = null) { + public function call($endpoint, $method = 'GET', $object = null, $odata = null) { $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @@ -33,10 +33,21 @@ public function call($endpoint, $method = 'GET', $object = null) { 'Content-Length: ' . strlen($json)) ); } + curl_setopt($ch, CURLOPT_URL, 'https://actionnetwork.org/api/v2/'.$endpoint); } else { curl_setopt($ch, CURLOPT_HTTPHEADER, array('OSDI-API-Token:'.$this->api_key)); + if ($odata != "") { + $request_parameters = array('filter'=>$odata); + $request_url = "https://actionnetwork.org/api/v2/".$endpoint; + $request_url .= "?".http_build_query($request_parameters); + curl_setopt($ch, CURLOPT_URL, $request_url); + } else { + $request_parameters = array('filter'=>$odata); + $request_url = "https://actionnetwork.org/api/v2/".$endpoint; + curl_setopt($ch, CURLOPT_URL, $request_url); + } + } - curl_setopt($ch, CURLOPT_URL, 'https://actionnetwork.org/api/v2/'.$endpoint); $response = curl_exec($ch); From bb5d5b1825bdf9430159e1f73ab89f84cf3eb6e5 Mon Sep 17 00:00:00 2001 From: Typel Date: Fri, 19 Feb 2016 15:47:17 -0500 Subject: [PATCH 2/2] Update actionnetwork.class.php --- actionnetwork.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/actionnetwork.class.php b/actionnetwork.class.php index 3dd57d2..115e674 100644 --- a/actionnetwork.class.php +++ b/actionnetwork.class.php @@ -42,7 +42,6 @@ public function call($endpoint, $method = 'GET', $object = null, $odata = null) $request_url .= "?".http_build_query($request_parameters); curl_setopt($ch, CURLOPT_URL, $request_url); } else { - $request_parameters = array('filter'=>$odata); $request_url = "https://actionnetwork.org/api/v2/".$endpoint; curl_setopt($ch, CURLOPT_URL, $request_url); }