@param string $method HTTP verb
@param string $type
@param array  $params

@return bool
@throws \ostark\upper\exceptions\CloudflareApiException
169084
protected function sendRequest($method = 'DELETE', string $type, array $params = [])
    {
        $client = new Client([
            'base_uri' => self::API_ENDPOINT,
            'headers'  => [
                'Content-Type' => 'application/json',
                'X-Auth-Key'   => $this->apiKey,
                'X-Auth-Email' => $this->apiEmail,
            ]
        ]);

        try {

            $uri     = "zones/{$this->zoneId}/$type";
            $options = (count($params)) ? ['json' => $params] : [];
            $client->request($method, $uri, $options);

        } catch (BadResponseException $e) {

            throw CloudflareApiException::create(
                $e->getRequest(),
                $e->getResponse()
            );
        }

        return true;
    }
634827
public function api($endpoint, array $params = [], $method = Method::GET)
    {
        $headers = $this->getApiHeaders();
        $options = $this->prepareOptions($params, $method);
        Method::isMethodSupported($method);
        if ($this->isUsingTokenParam()) {
            $params['oauth2_access_token'] = $this->accessToken->getToken();
        } else {
            $headers['Authorization'] = 'Bearer ' . $this->accessToken->getToken();
        }
        $guzzle = new GuzzleClient([
            'base_uri' => $this->getApiRoot(),
            'headers' => $headers,
        ]);
        if (!empty($params) && Method::GET === $method) {
            $endpoint .= '?' . build_query($params);
        }
        try {
            $response = $guzzle->request($method, $endpoint, $options);
        } catch (RequestException $requestException) {
            throw Exception::fromRequestException($requestException);
        }
        return self::responseToArray($response);
    }
694433
protected function request($url, $method = 'GET', array $params = array())
    {
        $this->client->setEventDispatcher($this->getEventDispatcher());
        $this->client->activatePlugins($this->registerPlugins);

        $response = $this->client->request($method, $url, $params);
        return $response;
    }
639411
public function api($endpoint, $method, $params = null)
    {
        $method = strtolower($method);

        try {
            $response = $this->app['twitter']->$method($endpoint, $params);
        } catch (\Exception $e) {
            $this->app['logger']->error($e);

            return false;
        }

        // log certain errors like rate limiting or expired tokens
        if (is_object($response) && property_exists($response, 'errors')) {
            foreach ($response->errors as $error) {
                if ($error->code == 88) {
                    $this->app['logger']->error("Hit Twitter rate limit on $endpoint with params: ".json_encode($params));
                } elseif ($error->code == 89) { // expired access token
                    // clear the access token of the user's profile
                    if ($this->profile) {
                        $this->profile->grantAllPermissions();
                        $this->profile->set(['access_token' => '', 'access_token_secret' => '']);
                        $this->profile->enforcePermissions();
                    }

                    // $this->app[ 'logger' ]->error( "Twitter access token expired on $endpoint with params: " . json_encode( $params ) );
                } elseif ($error->code == 231) {
                    $this->app['logger']->error("User must verify twitter login on $endpoint with params: ".json_encode($params));
                }
            }
        }

        return $response;
    }
1059858
private function api($method, $params) 
	{
    
		$basic = array(
		  'method'      => $method,
		  'appid'       => $this->appid,
		  'key'         => $this->key,
		  'path'        => $this->path,
		  'user_ip'     => $_SERVER['REMOTE_ADDR'],
		  'language'    => $this->language,
		  'platform'    => 'php'
		);

		return $this->call(array_merge(isset($params[0]) ? $params[0] : $params, $basic));
	}
1045338
protected function call( $type, $params ) {
		if ( !isset( $this->callbacks[$type] ) ) {
			return;
		}
		foreach ( $this->callbacks[$type] as $callback ) {
			if ( is_callable( $callback ) ) {
				call_user_func_array( $callback, $params );
			}
		}
	}
792742
public function api($method, $params = array())
    {
        if (!in_array($method, $this->supportedUnitpayMethods)) {
            throw new UnexpectedValueException('Method is not supported');
        }

        if (isset($this->requiredUnitpayMethodsParams[$method])) {
            foreach ($this->requiredUnitpayMethodsParams[$method] as $rParam) {
                if (!isset($params[$rParam])) {
                    throw new InvalidArgumentException('Param '.$rParam.' is null');
                }
            }
        }

        $params['secretKey'] = $this->secretKey;
        if (empty($params['secretKey'])) {
            throw new InvalidArgumentException('SecretKey is null');
        }

        $requestUrl = self::API_URL . '?' . http_build_query([
            'method' => $method,
            'params' => $params
        ], null, '&', PHP_QUERY_RFC3986);

        $response = json_decode(file_get_contents($requestUrl));
        if (!is_object($response)) {
            throw new InvalidArgumentException('Temporary server error. Please try again later.');
        }

        return $response;
    }
980673
public static function sendRequest($method = 'sendMessage', $params)
    {
        $curl = curl_init(self::$api_url . self::$api_token . '/'. $method);
        curl_setopt($curl, CURLOPT_HEADER, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params));
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

        if(self::$proxy) {
            curl_setopt_array($curl, self::setProxy());
        }

        $curl_result = curl_exec($curl);
        $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        curl_close($curl);

        if ($http_code != 200) {
            if ($curl_result) {
                $curl_result = json_decode($curl_result, true);
                throw new \Exception($curl_result['description']);
            }
            throw new \Exception('an error was encountered');
        }

        return $curl_result;
    }
1235684
public function request($method, array $params = [])
    {
        return new Request($this->endpoint, $this->secret, $method, $params);
    }
713364
protected function call($method, array $params)
    {
        $uri = $this->getConfig('base_url') . '/xmlrpc.php';
        $bridge = new \fXmlRpc\Transport\GuzzleBridge($this);
        $client = new \fXmlRpc\Client($uri, $bridge);

        // We have to nest the params in an array otherwise we get a "Wrong
        // number of method parameters" error.
        return $client->call($method, array($params));
    }
183319
private function makeRequest($method, $uri, array $parameters = []) {
    try {
      $response = $this->request($method, $uri, $parameters);
      
      if (200 != $response->getStatusCode()) {
        throw new ActivenetClientException(sprintf('Got non 200 response code for the uri %s.', $uri));
      }

      if (!$body = $response->getBody()) {
        throw new ActivenetClientException(sprintf('Failed to get response body for the uri %s.', $uri));
      }

      if (!$contents = $body->getContents()) {
        throw new ActivenetClientException(sprintf('Failed to get body contents for the uri: %s.', $uri));
      }

      $object = json_decode($contents);

      // Check if object contains data.
      if (isset($object->body)) {
        return $object->body;
      }

      throw new ActivenetClientException(sprintf('Got unknown body name for method %s.', $method));
    }
    catch (\Exception $e) {
      throw new ActivenetClientException(sprintf('Failed to make a request for uri %s with message %s.', $uri, $e->getMessage()));
    }

  }
370775
public function sendRequest($method, $params = [])
    {
        $request = $this->request($method, $params);
        $this->lastResponse = $this->client->sendRequest($request);
        if ($this->lastResponse->isError()) {
            $this->lastResponse->throwException();
        }

        return $this->lastResponse;
    }
390886
protected function runTemplate($method, array $params=[]) {
		ob_start();
		$result         = call_user_func_array([$this, $method], $params);
		$viewableBuffer = ob_get_clean();

		#result returned by method?
		if($result !== null) {
			if($result instanceof TemplateInterface) {
				if(!$result->getEngine() && $this->templateEngine)
					$result->setEngine($this->templateEngine);
				return $result->render();
			}
			elseif(is_numeric($result))
				return (string)$result;
			else
				return $result;
		}
		#output from method?
		elseif($viewableBuffer)
			return $viewableBuffer;
		#given view?
		elseif($this->view) {
			#given template engine?
			if($this->templateEngine)
				return $this->templateEngine->createTemplate()->render($this->view, (array)$this);
			#use the default render technique
			else
				return $this->renderDefaultTemplate($this->view, (array)$this);
		}
		#default view
		elseif($this->defaultView) {
			#given template engine?
			if($this->templateEngine) {
				$engine = $this->templateEngine;
				if($engine->templateExists($this->defaultView))
					return $engine->createTemplate()->render($this->defaultView, (array)$this);
			}
			#use the default render technique
			elseif($this->templateExists($this->defaultView))
				return $this->renderDefaultTemplate($this->defaultView, (array)$this);
		}
		#nothing to return
		return null;
	}
1244851
public function request($method, $params = [])
    {
        $response = $this->client->post($this->getUrl($method), ['query' => $params]);

        if ($response->getStatusCode() === 200) {
            return (string)$response->getBody();
        } else {
            throw new Exception(sprintf('Sms.ru problem. Status code is %s', $response->getStatusCode()), $response->getStatusCode());
        }
    }
1143802
protected function request($method, $param = array(), $catchException = true)
    {
        if (!$this->session) {
            $this->login();
        }
        $this->lastException = null;
        try {

            // add as first parameter the session
            array_unshift($param, $this->session);
            $response = call_user_func_array(array($this->soapClient, $method), $param);
        } catch (\SoapFault $e) {
            if ($catchException) {
                $this->lastException = $e;

                return false;
            } else {
                throw $e;
            }
        }

        return $response;
    }
855362
public function invokeMethod($method, $params)
    {
        // for named parameters, convert from object to assoc array
        if (is_object($params)) {
            $array = array();
            foreach ($params as $key => $val) {
                $array[$key] = $val;
            }
            $params = array($array);
        }
        // for no params, pass in empty array
        if ($params === null) {
            $params = array();
        }
        $reflection = new \ReflectionMethod($this->exposed_instance, $method);
        
        // only allow calls to public functions
        if (!$reflection->isPublic()) {
            throw new Serverside\Exception("Called method is not publically accessible.");
        }

        // enforce correct number of arguments
        $num_required_params = $reflection->getNumberOfRequiredParameters();
        if ($num_required_params > count($params)) {
            throw new Serverside\Exception("Too few parameters passed.");
        }
        
        return $reflection->invokeArgs($this->exposed_instance, $params);
    }
641221
public function call($method, $params=[]) {
    $result = explode('/',$method);
    $class = $result[0];
    $method = $result[1];

    $valid_classes = [
     'image' => 'JohnVanOrange\API\Image',
     'user' => 'JohnVanOrange\API\User',
     'tag' => 'JohnVanOrange\API\Tag',
     'report' => 'JohnVanOrange\API\Report',
     'reddit' => 'JohnVanOrange\API\Reddit',
     'media' => 'JohnVanOrange\API\Media',
     'setting' => 'JohnVanOrange\API\Setting',
     'blacklist' => 'JohnVanOrange\API\Blacklist',
     'message' => 'JohnVanOrange\API\Message',
     'test' => 'JohnVanOrange\API\Test'
     ];
    switch ($class) {
     case 'image':
     case 'user':
     case 'tag':
     case 'report':
     case 'reddit':
     case 'media':
     case 'setting':
     case 'blacklist':
     case 'message':
     case 'test':
      $class_name =  $valid_classes[$class];
      break;
     default:
      throw new \JohnVanOrange\Core\Exception\Invalid('Invalid class/URL');
     break;
    }

    $reflectClass = new \ReflectionClass($class_name);
    $reflectMethod = $reflectClass->getMethod($method);
    $reflectParams = $reflectMethod->getParameters();

    $indexed_params = [];

    foreach($reflectParams as $param) {
     if (isset($params[$param->getName()])) {
      $indexed_params[] = $params[$param->getName()];
     } else {
      if ($param->isOptional()) {
       $indexed_params[] = $param->getDefaultValue();
      } else {
       $indexed_params[] = NULL;
      }
     }
    }

    $class_obj = new $class_name;

    return $reflectMethod->invokeArgs($class_obj, $indexed_params);
 }