public function send($json, $notify = false)
    {
        // use http authentication header if set
        $header = "Content-Type: application/json\r\n";
        if ($this->authHeader) {
            $header .= $this->authHeader;
        }

        // prepare data to be sent
        $opts = array(
            'http' => array(
                'method'  => 'POST',
                'header'  => $header,
                'content' => $json));
        $context = stream_context_create($opts);

        // try to physically send data to destination 
        try {
            $response = file_get_contents($this->uri, false, $context);
        } catch (\Exception $e) {
            $message = "Unable to connect to {$this->uri}";
            $message .= PHP_EOL . $e->getMessage();
            throw new Clientside\Exception($message);
        }

        // handle communication errors
        if ($response === false) {
            throw new Clientside\Exception("Unable to connect to {$this->uri}");
        }

        // notify has no response
        if ($notify) {
            return true;
        }

        // try to decode json
        $json_response = $this->decodeJSON($response);

        // handle response, create response object and return it
        return $this->handleResponse($json_response);
    }
public function send($json, $notify = false)
    {
        // use http authentication header if set
        $header = "Content-Type: application/json\r\n";
        if ($this->authHeader) {
            $header .= $this->authHeader;
        }

        // prepare data to be sent
        $opts = array(
            'http' => array(
                'method'  => 'POST',
                'header'  => $header,
                'content' => $json));
        $context = stream_context_create($opts);

        // try to physically send data to destination 
        try {
            $response = file_get_contents($this->uri, false, $context);
        } catch (\Exception $e) {
            $message = "Unable to connect to {$this->uri}";
            $message .= PHP_EOL . $e->getMessage();
            throw new Clientside\Exception($message);
        }

        // handle communication errors
        if ($response === false) {
            throw new Clientside\Exception("Unable to connect to {$this->uri}");
        }

        // notify has no response
        if ($notify) {
            return true;
        }

        // try to decode json
        $json_response = $this->decodeJSON($response);

        // handle response, create response object and return it
        return $this->handleResponse($json_response);
    }
public function send ( $ json , $ notify = false ) { // use http authentication header if set $ header = "Content-Type: application/json\r\n" ; if ( $ this -> authHeader ) { $ header .= $ this -> authHeader ; } // prepare data to be sent $ opts = array ( 'http' => array ( 'method' => 'POST' , 'header' => $ header , 'content' => $ json ) ) ; $ context = stream_context_create ( $ opts ) ; // try to physically send data to destination  try { $ response = file_get_contents ( $ this -> uri , false , $ context ) ; } catch ( \ Exception $ e ) { $ message = "Unable to connect to {$this->uri}" ; $ message .= PHP_EOL . $ e -> getMessage ( ) ; throw new Clientside \ Exception ( $ message ) ; } // handle communication errors if ( $ response === false ) { throw new Clientside \ Exception ( "Unable to connect to {$this->uri}" ) ; } // notify has no response if ( $ notify ) { return true ; } // try to decode json $ json_response = $ this -> decodeJSON ( $ response ) ; // handle response, create response object and return it return $ this -> handleResponse ( $ json_response ) ; }
send raw json to the server
send raw json to the server