perform api call

@param RemoteApp $oRemoteApp

@return mixed
320349
private function _makeCall($oRemoteApp)
        {

            // get class
            $this->getContainer()->get('API');
            // do call
            Api::$_container = $this->getContainer();
            $aReturn = Api::call('getData', array(
                array(
                    'log'    => $oRemoteApp->getIncludelog(),
                    'format' => 'json'
                )
            ), $oRemoteApp->getFullApiUrl(), $oRemoteApp->getPublicKey(), $oRemoteApp);

            // build json response
            $sStatuscode = $aReturn['statuscode'];
            $aReturn     = json_decode($aReturn['result'], true);
            if (!isset($aReturn['status'])) {
                $aReturn['status'] = true;
            }
            $aReturn['statuscode'] = $sStatuscode;

            if($sStatuscode != 200) {
                $this->getContainer()->get('logger')->error("ERROR in ".__FILE__." on line ".__LINE__." - ".json_encode($aReturn), array("Method"    => __METHOD__,
                                                                     "RemoteApp" => $oRemoteApp->getName(),
                                                                     "RemoteURL" => $oRemoteApp->getFullApiUrl()
                ));
            }

            return $aReturn;
        }
311954
private function _sendNotification($aDiff, &$oRemoteApp, $aNewHistory)
        {

            // parse template
            $sHtml = $this->getContainer()->get('templating')->render('SlashworksAppBundle:Email:cron_notification.html.twig', array(
                'diff'       => $aDiff,
                'log'        => $aNewHistory['Log'],
                'remote_app' => $oRemoteApp,
                'controlurl' => $this->_getSiteURL()
            ));

            // get recipients
            $sRecipient = $oRemoteApp->getNotificationRecipient();
            // get sender
            $sSender = $oRemoteApp->getNotificationSender();

            // set subject and body of mail
            $sMessage = \Swift_Message::newInstance()->setSubject($this->getContainer()->get('translator')->trans('system.email.change.subject'))->setFrom($sSender)->setTo($sRecipient)->setContentType('text/html')->setBody($sHtml, 'text/html')->addPart($sHtml, 'text/html');

            // send email
            $this->getContainer()->get('mailer')->send($sMessage);
        }
1278902
private function _request($method, $params = array(), $url = self::API_ENDPOINT) {
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_USERAGENT, 'Elvanto_API-PHP/1.0.0');
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
		curl_setopt($ch, CURLOPT_POST, true);
		curl_setopt($ch, CURLOPT_HEADER, false);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
		curl_setopt($ch, CURLOPT_TIMEOUT, 10);
		// Exchange or refresh a token
		if ($method === 'oauth') {
			$headers = array('Content-Type: application/x-www-form-urlencoded');
			curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
		// Call an API method
		} else {
			$url = self::API_ENDPOINT . '/' . $method . '.json';
			$params['grant_type'] = 'client_credentials';
			$headers = array('Content-Type: application/json; charset=utf-8');
			if (isset($this->auth_details['access_token'])) { // Authenticating using OAuth
				$headers[] = 'Authorization: Bearer ' . $this->auth_details['access_token'];
			} else if (isset($this->auth_details['api_key'])) { // Authenticating using an API key
				curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
				curl_setopt($ch, CURLOPT_USERPWD, $this->auth_details['api_key'] . ':nopass');
			}
			curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
		}
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
		$response = curl_exec($ch);
		if (curl_error($ch)) {
			trigger_error('API call to ' . $url . ' failed: ' . curl_error($ch), E_USER_ERROR);
			return false;
		}
		curl_close($ch);
		return $response ? json_decode($response) : false;
	}
301309
public function deleteAction(Request $request, $id)
        {

            /** @var RemoteApp $oRemoteApp */
            $oRemoteApp = RemoteAppQuery::create()->findOneById($id);

            if ($oRemoteApp === null) {
                throw $this->createNotFoundException('Unable to find RemoteApp entity.');

            }

            // get history-entries for remoteapp to delete
            $aHistories = RemoteHistoryContaoQuery::create()->findByRemoteAppId($oRemoteApp->getId());
            foreach ($aHistories as $oHistory) {
                $oHistory->delete();
            }
            $oRemoteApp->delete();

            return $this->redirect($this->generateUrl('remote_app'));
        }
144034
private function jsonCall($method, $uri, $body = null)
    {
        $jsonBody = null;

        if (null !== $body) {
            $jsonBody = json_encode($body);
        }

        $request = new Request($method, $uri, ['Content-Type' => 'application/json'], $jsonBody);
        $response = $this->guzzle->send($request);
        $this->lastResponse = $response;

        self::checkResponse($response);

        return json_decode($response->getBody());
    }
1039347
protected function xmlrpc_call($method, $array)
    {
        $this->_checkConfig();

        if (!isset($method) || !is_string($method)) {
            throw new Klarna_InvalidTypeException('method', 'string');
        }
        if ($array === null || count($array) === 0) {
            throw new KlarnaException("Parameterlist is empty or null!", 50067);
        }
        if (self::$disableXMLRPC) {
            return true;
        }
        try {
            /*
             * Disable verifypeer for CURL, so below error is avoided.
             * CURL error: SSL certificate problem, verify that the CA
             * cert is OK.
             * Details: error:14090086:SSL
             * routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (#8)
             */
            $this->xmlrpc->verifypeer = false;

            $timestart = microtime(true);

            //Create the XMLRPC message.
            $msg = new xmlrpcmsg($method);
            $params = array_merge(
                array(
                    $this->PROTO, $this->VERSION
                ), $array
            );

            $msg = new xmlrpcmsg($method);
            foreach ($params as $p) {
                if (!$msg->addParam(
                    php_xmlrpc_encode($p, array('extension_api'))
                )
                ) {
                    throw new KlarnaException(
                        "Failed to add parameters to XMLRPC message.",
                        50068
                    );
                }
            }

            $selectDateTime = microtime(true);
            if (self::$xmlrpcDebug) {
                $this->xmlrpc->setDebug(2);
            }
            //Save previous XML RPC client encoding settings.
            $tmp_xmlrpc_defencoding = $GLOBALS['xmlrpc_defencoding'];
            $tmp_xmlrpc_internalencoding = $GLOBALS['xmlrpc_internalencoding'];
            //Set XML RPC client encoding settings.
            $GLOBALS['xmlrpc_defencoding'] = 'ISO-8859-1';
            $GLOBALS['xmlrpc_internalencoding'] = 'UTF-8';

            //Send the message.
            $xmlrpcresp = $this->xmlrpc->send($msg);

            //Restore previous XML RPC client encoding settings.
            $GLOBALS['xmlrpc_defencoding'] = $tmp_xmlrpc_defencoding;
            $GLOBALS['xmlrpc_internalencoding'] = $tmp_xmlrpc_internalencoding;

            //Calculate time and selectTime.
            $timeend = microtime(true);
            $time = (int) (($selectDateTime - $timestart) * 1000);
            $selectTime = (int) (($timeend - $timestart) * 1000);

            $status = $xmlrpcresp->faultCode();

            if ($status !== 0) {
                throw new KlarnaException($xmlrpcresp->faultString(), $status);
            }

            return php_xmlrpc_decode($xmlrpcresp->value());
        }
        catch(KlarnaException $e) {
            //Otherwise it is caught below, and rethrown.
            throw $e;
        }
        catch(Exception $e) {
            throw new KlarnaException($e->getMessage(), $e->getCode());
        }
    }
477910
public static function call($method, $params, $url, $publickey, $oRemoteApp = null)
        {

            $response = "";
            try {
                $sOldErrorhandler = set_error_handler('Slashworks\AppBundle\Services\Api::errorHandler');

                if(!self::$_container){
                    throw new \InvalidArgumentException("Container not given...");
                }


                if (!is_scalar($method)) {
                    throw new \Exception('Method name has no scalar value');
                }

                // check
                if (is_array($params)) {
                    // no keys
                    $params = array_values($params);
                } else {
                    throw new \Exception('Params must be given as array');
                }

                // prepares the request
                $request = array(
                    'method' => $method,
                    'params' => $params,
                    'id'     => rand(1, 999)
                );
                $request = json_encode($request);


                $rsa = new \Crypt_RSA();
                $rsa->loadKey($publickey);



                $sAppPath = self::$_container->get('kernel')->getRootDir();
                $sVendorPath = $sAppPath."/../vendor/slashworks/control-bundle/src/Slashworks/";
                $sKeyPath = $sVendorPath."AppBundle/Resources/private/api/keys/server/";

                $conairKey = file_get_contents($sKeyPath . "public.key");
                $aRequest  = array(
                    'pkey' => $conairKey,
                    'data' => base64_encode($rsa->encrypt($request))
                );

                $sRequest = json_encode($aRequest);

                $headers = array(
                    'Content-Type: application/json'
                );

                if ($oRemoteApp->getApiAuthType() == "http-basic") {
                    $sUsername = $oRemoteApp->getApiAuthHttpUser();
                    $sPassword = $oRemoteApp->getApiAuthHttpPassword();
                    if (!empty($sUsername) && !empty($sPassword)) {
                        $headers[] = "Authorization: Basic " . base64_encode($oRemoteApp->getApiAuthHttpUser() . ":" . $oRemoteApp->getApiAuthHttpPassword());
                    }
                }
                $oRequest = curl_init($url);
                curl_setopt($oRequest, CURLOPT_HTTPHEADER, $headers);
                curl_setopt($oRequest, CURLOPT_TIMEOUT, 5);
                curl_setopt($oRequest, CURLOPT_POST, 1);
                curl_setopt($oRequest, CURLOPT_POSTFIELDS, $sRequest);
                curl_setopt($oRequest, CURLOPT_RETURNTRANSFER, true);
                $response    = curl_exec($oRequest);
                $iHttpStatus = curl_getinfo($oRequest, CURLINFO_HTTP_CODE);
                $error = curl_error($oRequest);
                curl_close($oRequest);

                $rawResponse = $response;

                if ($response == "") {
                    throw new \Exception("No content received for call on: ".$url);
                }
                if ($iHttpStatus === 200) {
                    $response = json_decode($response, true);

                    if (!isset($response['data'])) {
                        throw new \Exception("Invalid response format: ".htmlentities($rawResponse));
                    }

                    $privateKey = file_get_contents(__DIR__ . "/../Resources/private/api/keys/server/private.key");
                    $rsa->loadKey($privateKey);
                    $data             = base64_decode($response['data']);
                    $decoded          = $rsa->decrypt($data);
                    $response['data'] = json_decode($decoded, true);
                    if (!is_array($response['data'])) {
                        throw new \Exception("Invalid response format: ".htmlentities($rawResponse));
                    }

                    $response['data']['statuscode'] = $iHttpStatus;
                    if($iHttpStatus !== 200){
                        $response['error'] = true;
                    }


                    ApiLog::create($iHttpStatus, $oRemoteApp->getId(), $decoded);


                    restore_error_handler();

                    return $response['data'];
                } else {

                    ApiLog::create($iHttpStatus, $oRemoteApp->getId(), $response);

                    restore_error_handler();

                    return array(
                        "statuscode" => $iHttpStatus,
                        "result"     => json_encode(array(
                                                        "status"     => false,
                                                        "error"     => true,
                                                        "statuscode" => $iHttpStatus,
                                                        "message"    => $response
                                                    )
                        )
                    );
                }


            } catch (ContextErrorException $e) {

                restore_error_handler();
                ApiLog::create(-1, $oRemoteApp->getId(), $e->getMessage());


                return array(
                    "statuscode" => $iHttpStatus,
                    "result"     => json_encode(array(
                                                    "status"     => false,
                                                    "error"     => true,
                                                    "statuscode" => -1,
                                                    "message"    => $e->getMessage()
                                                )
                    )
                );
            } catch (\Exception $e) {


                restore_error_handler();
                ApiLog::create(-1, $oRemoteApp->getId(), $e->getMessage());

                return array(
                    "statuscode" => 500,
                    "result"     => json_encode(array(
                                                    "status"     => false,
                                                    "error"     => true,
                                                    "statuscode" => -1,
                                                    "message"    => $e->getMessage()
                                                )
                    )
                );
            }
        }
404748
protected function fetchReply($rpl)
  {
    foreach($rpl as $key => $val)
    {
      if($val->startsWith(TeamSpeak3::GREET))
      {
        unset($rpl[$key]);
      }
      elseif($val->startsWith(TeamSpeak3::EVENT))
      {
        $this->evt[] = new TeamSpeak3_Adapter_ServerQuery_Event($rpl[$key], $this->con);
        unset($rpl[$key]);
      }
    }

    $this->rpl = new TeamSpeak3_Helper_String(implode(TeamSpeak3::SEPARATOR_LIST, $rpl));
  }
648435
async def RemoteApplicationInfo(self, offer_urls):
        '''
        
        '''
        # map input types to rpc msg
        _params = dict()
        msg = dict(type='ApplicationOffers',
                   request='RemoteApplicationInfo',
                   version=2,
                   params=_params)
        _params['offer-urls'] = offer_urls
        reply = await self.rpc(msg)
        return reply
1287063
private function remoteCall()
    {

        if (function_exists(
            'wp_remote_head'
        )) { // Check if this is being used with WordPress, if so use it's excellent HTTP class

            $response = wp_remote_head($this->tracking);
            return $response;

        } elseif (function_exists('curl_init')) {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $this->tracking);
            curl_setopt($ch, CURLOPT_HEADER, false);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //@nczz Fixed HTTPS GET method
            curl_setopt($ch, CURLOPT_TIMEOUT, 10);
            curl_exec($ch);
            curl_close($ch);
        } else {
            $handle = fopen($this->tracking, "r");
            fclose($handle);
        }
        return;
    }
831071
public function call(string $method, $payload, int $flags = 0)
    {
        $this->relay->send(
            $method . pack("P", $this->seq),
            Relay::PAYLOAD_CONTROL | Relay::PAYLOAD_RAW
        );

        if ($flags & Relay::PAYLOAD_RAW) {
            $this->relay->send($payload, $flags);
        } else {
            $body = json_encode($payload);
            if ($body === false) {
                throw new Exceptions\ServiceException(sprintf(
                    "json encode: %s",
                    json_last_error_msg()
                ));
            }

            $this->relay->send($body);
        }

        $body = $this->relay->receiveSync($flags);

        if (!($flags & Relay::PAYLOAD_CONTROL)) {
            throw new Exceptions\TransportException("rpc response header is missing");
        }

        $rpc = unpack("Ps", substr($body, -8));
        $rpc['m'] = substr($body, 0, -8);

        if ($rpc["m"] != $method || $rpc["s"] != $this->seq) {
            throw new Exceptions\TransportException("rpc method call mismatch");
        }

        // request id++
        $this->seq++;

        // wait for the response
        $body = $this->relay->receiveSync($flags);

        return $this->handleBody($body, $flags);
    }
561421
public function updateApiApp($client_id, ApiApp $app)
    {
        $response = $this->rest->post(
            static::APIAPP_PATH . '/' . $client_id,
            $app->toUpdateParams()
        );

        $this->checkResponse($response);

        return $app->fromResponse($response);
    }
1085976
public function getRecommListArticlesUrl(\OxidEsales\Eshop\Application\Model\RecommendationList $oRecommList)
    {
        $oLang = Registry::getLang();
        $iLang = $oLang->getBaseLanguage();

        return $this->_prepareUrl(
            "cl=rss&amp;fnc=recommlistarts&amp;recommid=" . $oRecommList->getId(),
            $oLang->translateString("LISTMANIA", $iLang) . "/" . $oRecommList->oxrecommlists__oxtitle->value
        );
    }
1074102
public function verify($reCaptchaResponse, $remoteIp = null)
    {
        $options = ['secret' => $this->clientSecret, 'response' => $reCaptchaResponse];

        if (null !== $remoteIp) {
            $options['remoteip'] = $remoteIp;
        }

        $result = $this->request('siteverify', $options, 'POST');
        $this->lastErrors = isset($result['error-codes']) ? $result['error-codes'] : [];

        return $result['success'];
    }
944314
protected function executeController($controller_esp, $uriapp = NULL) {
        if (count($controller_esp['middlewares']) > 0) {
            if ($this->executeMiddlewares($controller_esp['middlewares']) === false) {
                return;
            }
        }
        
        $dir= $this->buildDir($controller_esp);
        $class= $this->buildClass($controller_esp);
        if(!class_exists($class)){
            //Si la clase no existe intento cargarla
            if(file_exists($dir)){
                require_once $dir;
            }else{
                //Avisa que el archivo no existe
                Error::general_error('Controller Error', 'The controller ' . $controller_esp['class'] . ' dont exists');
            } 
        }
        $controller= new $class();
        //Agrego los parametros URI
        $uri_params= UrlUri::uriParams($controller_esp['url'], $uriapp);
        $dinamic_method= $uri_params['dinamic'];
        $method= $uri_params['method']; 
        $parameters= $uri_params['params'] ? $uri_params['params'] : array();
        //Analizo si hay parametros en la configuracion
        if(isset($controller_esp['properties'])){
            $this->app->dependenciesEngine->injectProperties($controller, $controller_esp['properties']);
        }       
        //Saca el metodo HTPP y en base a eso hace una llamada al metodo correspondiente
        $methodHttp= filter_input(INPUT_SERVER, 'REQUEST_METHOD');
        if($dinamic_method){
            if($method != 'index' && !(method_exists($controller, $methodHttp . '_' . $method) || method_exists($controller, $method))){
                $parameters= array_merge(array('0' => $method), $parameters);
                $method= 'index';                
            }
            if(method_exists($controller, $methodHttp . '_' . $method)){
                $method= $methodHttp . '_' . $method;
            }
        }else if(isset($controller_esp['method'])){
            $method= $controller_esp['method'];
        }else{
            $method= "do" . ucfirst(strtolower($methodHttp));
        }
        $controller->setUriParams($parameters);
        if(method_exists($controller, $method)){
            $controller->$method($this->httpRequest, $this->httpResponse);
        }else{
            Error::general_error('HTTP Method Error', "The HTTP method $method is not supported");
        }
    }
838468
public function call($method)
    {
        $args = func_get_args();
        $data = call_user_func_array(array($this->_jiraClient, 'call'), $args);
        return $this->returnObjectArray($data, '\Jira\Remote\RemoteProject', 'key');
    }
536159
static public function fetchByRemoteID( $remoteID, $mainTranslation = false )
    {
        $tagsList = self::fetchList( array( 'remote_id' => $remoteID ), null, null, $mainTranslation );

        if ( is_array( $tagsList ) && !empty( $tagsList ) )
            return $tagsList[0];

        return null;
    }