API_BASE, 'defaults' => [ 'headers' => [ 'Content-type' => 'applications/json']]]); $url = API_BASE . $url . "/?format=json"; $result = $client->request('GET', $url); return $result->getBody(); } // Generic post function for REST API static function post($url, $data) { $client = new Client(['base_uri' => API_BASE, 'defaults' => [ 'headers' => [ 'Content-type' => 'applications/json']]]); $url = API_BASE . $url . "/?format=json"; $result = $client->request('POST', $url, array(), $data); return $result->getBody(); } // Asking for campaign informations static function get_campaign() { $json = Api::get("campaigns/" . CAMPAIGN_ID); return json_decode($json, true); } // Asking for complete list of contacts static function get_contacts() { $json = Api::get("campaigns/" . CAMPAIGN_ID . "/contacts"); return json_decode($json, true); } // Asking for a single contact static function get_contact($id) { $json = Api::get("campaigns/" . CAMPAIGN_ID . "/contacts/" . $id); return json_decode($json, true); } // Asking for complete list of groups static function get_groups() { $json = Api::get("campaigns/" . CAMPAIGN_ID . "/groups"); return json_decode($json, true); } // Asking for complete list of feedback categories static function get_feedback_categories() { $json = Api::get("campaigns/" . CAMPAIGN_ID . "/categories"); return json_decode($json, true); } // Asking for arguments by language static function get_arguments($language='en') { $json = Api::get("campaigns/" . CAMPAIGN_ID . "/arguments"); return json_decode($json, true); } // Posting a feedback static function post_feedback($contact_id, $comment, $feedback_category='') { $data = array( "contact_id"=>$contact_id, "comment"=>$comment, "feedback_category"=>$feedback_category ); $json = Api::post("campaigns/" . CAMPAIGN_ID . "/feedback/add", $data); return json_decode($json, true); } };