Using cURL to access 3rd Party API (Pushwoosh / JSON)

   //Official example: http://docs.pushwoosh.com/docs/createmessage#tag-conditions
    function pwCall($method, $data) {
        $url = 'https://cp.pushwoosh.com/json/1.3/' . $method;
        $request = json_encode(['request' => $data]);
     
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
        curl_setopt($ch, CURLOPT_HEADER, true);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
     
        $response = curl_exec($ch);
        $info = curl_getinfo($ch);
        curl_close($ch);
     
        if (defined('PW_DEBUG') && PW_DEBUG) {
            print "[PW] request: $request\n";
            print "[PW] response: $response\n";
            print "[PW] info: " . print_r($info, true);
        }

        //Remove header of JSON or parse will fail
        list(,$res_body) = explode("\n\r", $response, 2);
        $res = json_decode($res_body);
        //logg($res_body);

        if($res->status_code == 200){
            return true;
        }else{
            $this->err = $res->status_message;
            return false;
        }
    }

    //Without plugin, but failed because of unknown reason
    function native_test(){
        return $this->pwCall('createMessage', array(
                'application' => PW_APPLICATION,
                'auth' => PW_AUTH,
                'notifications' => array(
                    array(
                        'send_date' => 'now',
                        'content' => 'Send this content to user FINAL!~!!!!!', 
                        'data' => array('custom' => 'json data'), 
                        'conditions' => array(
                            array('HWID', 'EQ', $this->test_tag)
                        )
                    )
                )
            )
        );
    }