src/Chatkit.php
protected function createCurl($service_settings, $path, $jwt, $request_method, $body = null, $query_params = array())
    {
        $split_instance_locator = explode(':', $this->settings['instance_locator']);

        $scheme = 'https';
        $host = $split_instance_locator[1].'.pusherplatform.io';
        $service_path_fragment = $service_settings['service_name'].'/'.$service_settings['service_version'];
        $instance_id = $split_instance_locator[2];

        $full_url = $scheme.'://'.$host.'/services/'.$service_path_fragment.'/'.$instance_id.$path;
        $query = http_build_query($query_params);
        // Passing foo = [1, 2, 3] to query params will encode it as foo[0]=1&foo[1]=2
        // however, we want foo=1&foo=2 (to treat them as an array)
        $query_string = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $query);
        $final_url = $full_url.'?'.$query_string;

        $this->log('INFO: createCurl( '.$final_url.' )');

        return $this->createRawCurl($request_method, $final_url, $body, null, $jwt, true);
    }
protected function createCurl($service_settings, $path, $jwt, $request_method, $body = null, $query_params = array())
    {
        $split_instance_locator = explode(':', $this->settings['instance_locator']);

        $scheme = 'https';
        $host = $split_instance_locator[1].'.pusherplatform.io';
        $service_path_fragment = $service_settings['service_name'].'/'.$service_settings['service_version'];
        $instance_id = $split_instance_locator[2];

        $full_url = $scheme.'://'.$host.'/services/'.$service_path_fragment.'/'.$instance_id.$path;
        $query = http_build_query($query_params);
        // Passing foo = [1, 2, 3] to query params will encode it as foo[0]=1&foo[1]=2
        // however, we want foo=1&foo=2 (to treat them as an array)
        $query_string = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $query);
        $final_url = $full_url.'?'.$query_string;

        $this->log('INFO: createCurl( '.$final_url.' )');

        return $this->createRawCurl($request_method, $final_url, $body, null, $jwt, true);
    }
protected function createCurl ( $ service_settings , $ path , $ jwt , $ request_method , $ body = null , $ query_params = array ( ) ) { $ split_instance_locator = explode ( ':' , $ this -> settings [ 'instance_locator' ] ) ; $ scheme = 'https' ; $ host = $ split_instance_locator [ 1 ] . '.pusherplatform.io' ; $ service_path_fragment = $ service_settings [ 'service_name' ] . '/' . $ service_settings [ 'service_version' ] ; $ instance_id = $ split_instance_locator [ 2 ] ; $ full_url = $ scheme . '://' . $ host . '/services/' . $ service_path_fragment . '/' . $ instance_id . $ path ; $ query = http_build_query ( $ query_params ) ; // Passing foo = [1, 2, 3] to query params will encode it as foo[0]=1&foo[1]=2 // however, we want foo=1&foo=2 (to treat them as an array) $ query_string = preg_replace ( '/%5B(?:[0-9]|[1-9][0-9]+)%5D=/' , '=' , $ query ) ; $ final_url = $ full_url . '?' . $ query_string ; $ this -> log ( 'INFO: createCurl( ' . $ final_url . ' )' ) ; return $ this -> createRawCurl ( $ request_method , $ final_url , $ body , null , $ jwt , true ) ; }
Utility function used to create the curl object setup to interact with the Pusher API
Utility function used to create the curl object setup to interact with the Pusher API