Notifo_API::sendRequest PHP Method

sendRequest() public method

helper function to send the requests
public sendRequest ( $method, $type, $data )
$method - name of remote method to call
$type - HTTP method (GET, POST, etc)
$data - array with arguments for remote method
    function sendRequest($method, $type, $data)
    {
        $url = self::API_ROOT . self::API_VER . '/' . $method;
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        if ($type == "POST") {
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
        }
        curl_setopt($ch, CURLOPT_USERPWD, $this->apiUsername . ':' . $this->apiSecret);
        curl_setopt($ch, CURLOPT_HEADER, false);
        /*
         * if you are on a shared host or do not have access to install
         * the root CA certificates on your server, uncomment the next
         * two lines or the curl_exec call may fail with null
         */
        //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        $result = curl_exec($ch);
        $result = json_decode($result, true);
        return $result;
    }