public function call(
        $provider,
        $method,
        array $postParams = array(),
        array $queryParams = array(),
        $returnData = false
    ) {
        $this->code = -1;
        $this->data = array();
        $this->message = '';

        if (empty($provider)) {
            throw new Mobizon_Param_Required('You must provide "provider" parameter to MobizonApi::call.');
        }

        if (empty($method)) {
            throw new Mobizon_Param_Required('You must provide "method" parameter to MobizonApi::call.');
        }

        $queryDefaults = array(
            'api'    => $this->apiVersion,
            'apiKey' => $this->apiKey,
            'output' => $this->format
        );

        $queryParams = $this->applyParams($queryDefaults, $queryParams);
        $url = ($this->forceHTTP ? 'http' : 'https') . '://' . $this->apiServer . '/service/' . strtolower($provider) . '/' . strtolower($method) . '?';
        curl_setopt($this->curl, CURLOPT_URL, $url . http_build_query($queryParams));
        if (!empty($postParams)) {
            curl_setopt($this->curl, CURLOPT_POST, true);
            curl_setopt($this->curl, CURLOPT_POSTFIELDS, http_build_query($postParams));
        } else {
            curl_setopt($this->curl, CURLOPT_POST, false);
        }

        $result = curl_exec($this->curl);
        $error = curl_error($this->curl);
        if ($error) {
            throw new Mobizon_Http_Error('API call failed: ' . $error . '.');
        }

        $result = $this->decode($result);

        if (!is_object($result)) {
            throw new Mobizon_Http_Error('Bad API result: server returned unexpected result.');
        }

        $this->code = $result->code;
        $this->data = $result->data;
        $this->message = $result->message;

        return $returnData ? $this->getData() : (in_array($this->getCode(), array(0, 100)));
    }
public function call(
        $provider,
        $method,
        array $postParams = array(),
        array $queryParams = array(),
        $returnData = false
    ) {
        $this->code = -1;
        $this->data = array();
        $this->message = '';

        if (empty($provider)) {
            throw new Mobizon_Param_Required('You must provide "provider" parameter to MobizonApi::call.');
        }

        if (empty($method)) {
            throw new Mobizon_Param_Required('You must provide "method" parameter to MobizonApi::call.');
        }

        $queryDefaults = array(
            'api'    => $this->apiVersion,
            'apiKey' => $this->apiKey,
            'output' => $this->format
        );

        $queryParams = $this->applyParams($queryDefaults, $queryParams);
        $url = ($this->forceHTTP ? 'http' : 'https') . '://' . $this->apiServer . '/service/' . strtolower($provider) . '/' . strtolower($method) . '?';
        curl_setopt($this->curl, CURLOPT_URL, $url . http_build_query($queryParams));
        if (!empty($postParams)) {
            curl_setopt($this->curl, CURLOPT_POST, true);
            curl_setopt($this->curl, CURLOPT_POSTFIELDS, http_build_query($postParams));
        } else {
            curl_setopt($this->curl, CURLOPT_POST, false);
        }

        $result = curl_exec($this->curl);
        $error = curl_error($this->curl);
        if ($error) {
            throw new Mobizon_Http_Error('API call failed: ' . $error . '.');
        }

        $result = $this->decode($result);

        if (!is_object($result)) {
            throw new Mobizon_Http_Error('Bad API result: server returned unexpected result.');
        }

        $this->code = $result->code;
        $this->data = $result->data;
        $this->message = $result->message;

        return $returnData ? $this->getData() : (in_array($this->getCode(), array(0, 100)));
    }
public function call ( $ provider , $ method , array $ postParams = array ( ) , array $ queryParams = array ( ) , $ returnData = false ) { $ this -> code = - 1 ; $ this -> data = array ( ) ; $ this -> message = '' ; if ( empty ( $ provider ) ) { throw new Mobizon_Param_Required ( 'You must provide "provider" parameter to MobizonApi::call.' ) ; } if ( empty ( $ method ) ) { throw new Mobizon_Param_Required ( 'You must provide "method" parameter to MobizonApi::call.' ) ; } $ queryDefaults = array ( 'api' => $ this -> apiVersion , 'apiKey' => $ this -> apiKey , 'output' => $ this -> format ) ; $ queryParams = $ this -> applyParams ( $ queryDefaults , $ queryParams ) ; $ url = ( $ this -> forceHTTP ? 'http' : 'https' ) . '://' . $ this -> apiServer . '/service/' . strtolower ( $ provider ) . '/' . strtolower ( $ method ) . '?' ; curl_setopt ( $ this -> curl , CURLOPT_URL , $ url . http_build_query ( $ queryParams ) ) ; if ( ! empty ( $ postParams ) ) { curl_setopt ( $ this -> curl , CURLOPT_POST , true ) ; curl_setopt ( $ this -> curl , CURLOPT_POSTFIELDS , http_build_query ( $ postParams ) ) ; } else { curl_setopt ( $ this -> curl , CURLOPT_POST , false ) ; } $ result = curl_exec ( $ this -> curl ) ; $ error = curl_error ( $ this -> curl ) ; if ( $ error ) { throw new Mobizon_Http_Error ( 'API call failed: ' . $ error . '.' ) ; } $ result = $ this -> decode ( $ result ) ; if ( ! is_object ( $ result ) ) { throw new Mobizon_Http_Error ( 'Bad API result: server returned unexpected result.' ) ; } $ this -> code = $ result -> code ; $ this -> data = $ result -> data ; $ this -> message = $ result -> message ; return $ returnData ? $ this -> getData ( ) : ( in_array ( $ this -> getCode ( ) , array ( 0 , 100 ) ) ) ; }
Main method to call Mobizon API.

@param string $provider API provider name
@param string $method API method name
@param array $postParams POST params array
@param array $queryParams GET params array
@param bool $returnData Flag to return received data as result of this function instead of code (default behavior)
@throws Mobizon_Http_Error
@throws Mobizon_Param_Required
@return mixed
Main method to call Mobizon API .