request berupa CURL
978461
protected function _curl($data, $url)
	{
		//kalo tidak ada library curl, langsung gagal
		if ( ! function_exists("curl_init")) {
			return array(
				"output" => NULL,
				"status" => -1
			);
		}

		$data_string = json_encode($data);

		$curl = curl_init();
		curl_setopt($curl, CURLOPT_POST, true);
		curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
		curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($curl, CURLOPT_REFERER, "batudaa");
		curl_setopt($curl, CURLOPT_HTTPHEADER, array(
		    "Content-Type: application/json",
		    "Content-Length: " . strlen($data_string)
		));
		curl_setopt($curl, CURLOPT_URL, $url);

		$out = json_decode(curl_exec($curl));
		$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

		curl_close($curl);

		return array(
			"output" => $out,
			"status" => $status
		);
	}
869674
public function poll(): bool
    {
        // nothing to do?
        if (!$this->curlMultiMap) {
            return false;
        }

        do {
            $r = curl_multi_exec(
                $this->curlMultiHandle,
                $stillRunning
            );
        } while (CURLM_CALL_MULTI_PERFORM === $r);

        $messagesInQueue = 0;
        do {
            messageQueue:

            $status = curl_multi_info_read(
                $this->curlMultiHandle,
                $messagesInQueue
            );

            if ($status && CURLMSG_DONE === $status['msg']) {
                $resourceId = (int) $status['handle'];
                list(
                    $request,
                    $successCallback,
                    $errorCallback,
                    $retryCount) = $this->curlMultiMap[$resourceId];
                unset($this->curlMultiMap[$resourceId]);

                $curlHandle = $status['handle'];
                $curlResult = $this->parseResponse(curl_multi_getcontent($curlHandle), $curlHandle);
                $retry = false;

                if (self::STATUS_CURLERROR === $curlResult['status']) {
                    $e = new ClientException($curlResult['curl_errmsg'], $curlResult['curl_errno']);
                    $this->emit('exception', [$request, $e, &$retry, $retryCount]);

                    if ($retry) {
                        ++$retryCount;
                        $this->sendAsyncInternal($request, $successCallback, $errorCallback, $retryCount);
                        goto messageQueue;
                    }

                    $curlResult['request'] = $request;

                    if ($errorCallback) {
                        $errorCallback($curlResult);
                    }
                } elseif (self::STATUS_HTTPERROR === $curlResult['status']) {
                    $this->emit('error', [$request, $curlResult['response'], &$retry, $retryCount]);
                    $this->emit('error:'.$curlResult['http_code'], [$request, $curlResult['response'], &$retry, $retryCount]);

                    if ($retry) {
                        ++$retryCount;
                        $this->sendAsyncInternal($request, $successCallback, $errorCallback, $retryCount);
                        goto messageQueue;
                    }

                    $curlResult['request'] = $request;

                    if ($errorCallback) {
                        $errorCallback($curlResult);
                    }
                } else {
                    $this->emit('afterRequest', [$request, $curlResult['response']]);

                    if ($successCallback) {
                        $successCallback($curlResult['response']);
                    }
                }
            }
        } while ($messagesInQueue > 0);

        return count($this->curlMultiMap) > 0;
    }
397146
static function CallRest($p_url, $p_params = null, $p_data = null){
        $result = null;
        $url = $p_url;

        $params_attempt = new stdClass();
        $params_attempt->method = 'GET';
        $params_attempt->dataTypeRest = 'json';
        $params_attempt->debug = false;

        try {
            $params = (object) array_merge((array) $params_attempt, (array) $p_params);

            if($params->debug){
                echo('$p_url :');
                var_dump($p_url);
                echo('$params :');
                var_dump($params);
                echo('$p_data :');
                var_dump($p_data);
            }

            $curl = curl_init();

            switch ($params->method)
            {
                case "POST":
                    curl_setopt($curl, CURLOPT_POST, 1);

                    if ($p_data != null)
                        curl_setopt($curl, CURLOPT_POSTFIELDS, $p_data);
                    break;
                case "PUT":
                    curl_setopt($curl, CURLOPT_PUT, 1);
                    break;
                default:
                    if ($p_data != null)
                        $url = sprintf("%s?%s", $url, http_build_query($p_data));
            }

            // Optional Authentication:
            curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
            curl_setopt($curl, CURLOPT_USERPWD, "username:password");

            curl_setopt($curl, CURLOPT_URL, $url);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

            $retourCall = curl_exec($curl);

            curl_close($curl);

            switch ($params->dataTypeRest)
            {
                case "json":
                    $result = json_decode($retourCall);
                    break;
                default:
                    $result = $retourCall;
            }

            if($result == null){
                $result = $retourCall;
            }

            if($params->debug){
                echo('$result :');
                var_dump($result);
            }

            return $result;
        } catch (Exception $e) {
            $msg = $e->getMessage();
            Throw new \Exception('Erreur dans '.__CLASS__.' : '.$msg);
            return null;
        }
    }
138948
public function request() {
		if(!($vs_method = $this->getRequestMethod())) {
			return false;
		}

		$va_get = array();
		foreach($this->getAllGetParameters() as $vs_name => $vs_val) {
			$va_get[] = $vs_name."=".urlencode($vs_val);
		}

		if(strlen($this->ops_auth_token) > 0) {
			$va_get[] = 'authToken='.$this->ops_auth_token;
		}

		$vs_get = sizeof($va_get)>0 ? "?".join("&",$va_get) : "";

		$vs_query_url = preg_replace("/\/$/", '', $this->ops_service_url."/".$this->getEndpoint().$vs_get);
		$vo_handle = curl_init($vs_query_url);

		curl_setopt($vo_handle, CURLOPT_CUSTOMREQUEST, $vs_method);
		curl_setopt($vo_handle, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($vo_handle, CURLOPT_SSL_VERIFYHOST, 0);
		curl_setopt($vo_handle, CURLOPT_SSL_VERIFYPEER, 0);
		curl_setopt($vo_handle, CURLOPT_FOLLOWLOCATION, true);

		$va_body = $this->getRequestBody();
		if(is_array($va_body) && sizeof($va_body)>0) {
			curl_setopt($vo_handle, CURLOPT_POSTFIELDS, json_encode($va_body));
		}

		$vs_exec = curl_exec($vo_handle);
		$vn_code = curl_getinfo($vo_handle, CURLINFO_HTTP_CODE);
		curl_close($vo_handle);

		if($vn_code == 401) { // try to re-authenticate if access denied
			// discard previous token
			if(strlen($this->ops_auth_token)) {
				@file_put_contents($this->ops_token_storage_path, '');
			}

			if(!$this->authenticate()) { // make up json result for failed authentication
				return new ServiceResult('{ "ok": false, "errors": ["access denied"] }');
			} else { // auth successful, try again
				return $this->request();
			}
		}

		return new ServiceResult($vs_exec);
	}
613612
private function curlit() {
		$this->request_params = array();


		// configure curl
		$c = curl_init ();
		$useragent = (isset ( $this->config ['user_agent'] )) ? (empty ( $this->config ['user_agent'] ) ? 'XeroOAuth-PHP' : $this->config ['user_agent']) : 'XeroOAuth-PHP';
		curl_setopt_array ( $c, array (
				CURLOPT_USERAGENT => $useragent,
				CURLOPT_CONNECTTIMEOUT => $this->config ['curl_connecttimeout'],
				CURLOPT_TIMEOUT => $this->config ['curl_timeout'],
				CURLOPT_RETURNTRANSFER => TRUE,
				CURLOPT_SSL_VERIFYPEER => $this->config ['curl_ssl_verifypeer'],
				CURLOPT_CAINFO => $this->config ['curl_cainfo'],
				CURLOPT_SSL_VERIFYHOST => $this->config ['curl_ssl_verifyhost'],
				CURLOPT_FOLLOWLOCATION => $this->config ['curl_followlocation'],
				CURLOPT_PROXY => $this->config ['curl_proxy'],
				CURLOPT_ENCODING => $this->config ['curl_encoding'],
				CURLOPT_URL => $this->sign ['signed_url'],
				CURLOPT_VERBOSE => $this->config ['curl_verbose'],
				// process the headers
				CURLOPT_HEADERFUNCTION => array (
						$this,
						'curlHeader'
				),
				CURLOPT_HEADER => FALSE,
				CURLINFO_HEADER_OUT => TRUE
		) );

		if ($this->config ['application_type'] == "Partner") {
			curl_setopt_array ( $c, array (
					// ssl client cert options for partner apps
					CURLOPT_SSLCERT => $this->config ['curl_ssl_cert'],
					CURLOPT_SSLKEYPASSWD => $this->config ['curl_ssl_password'],
					CURLOPT_SSLKEY => $this->config ['curl_ssl_key']
			) );
		}

		if ($this->config ['curl_proxyuserpwd'] !== false)
			curl_setopt ( $c, CURLOPT_PROXYUSERPWD, $this->config ['curl_proxyuserpwd'] );

		if (isset ( $this->config ['is_streaming'] )) {
			// process the body
			$this->response ['content-length'] = 0;
			curl_setopt ( $c, CURLOPT_TIMEOUT, 0 );
			curl_setopt ( $c, CURLOPT_WRITEFUNCTION, array (
					$this,
					'curlWrite'
			) );
		}

		switch ($this->method) {
			case 'GET' :
				$contentLength = 0;
				break;
			case 'POST' :
				curl_setopt ( $c, CURLOPT_POST, TRUE );
				$post_body = $this->safe_encode ( $this->xml );
				curl_setopt ( $c, CURLOPT_POSTFIELDS, $post_body );
				$this->request_params ['xml'] = $post_body;
				$contentLength = strlen ( $post_body );

				break;
			case 'PUT' :
				$fh = tmpfile();
				if ($this->format == "file") {
					$put_body = $this->xml;
				} else {
					$put_body = $this->safe_encode ( $this->xml );
				}
				fwrite ( $fh, $put_body );
				rewind ( $fh );
				curl_setopt ( $c, CURLOPT_PUT, true );
				curl_setopt ( $c, CURLOPT_INFILE, $fh );
				curl_setopt ( $c, CURLOPT_INFILESIZE, strlen ( $put_body ) );
				$contentLength = strlen ( $put_body );

				break;
			default :
				curl_setopt ( $c, CURLOPT_CUSTOMREQUEST, $this->method );
		}

		if (! empty ( $this->request_params )) {
			// if not doing multipart we need to implode the parameters
			if (! $this->config ['multipart']) {
				foreach ( $this->request_params as $k => $v ) {
					$ps [] = "{$k}={$v}";
				}
				$this->request_payload = implode ( '&', $ps );
			}
			curl_setopt ( $c, CURLOPT_POSTFIELDS, $this->request_payload);
		} else {
			// CURL will set length to -1 when there is no data
			$this->headers ['Content-Type'] = '';
			$this->headers ['Content-Length'] = $contentLength;
		}

		$this->headers ['Expect'] = '';

		if (! empty ( $this->headers )) {
			foreach ( $this->headers as $k => $v ) {
				$headers [] = trim ( $k . ': ' . $v );
			}
			curl_setopt ( $c, CURLOPT_HTTPHEADER, $headers );
		}

		if (isset ( $this->config ['prevent_request'] ) && false == $this->config ['prevent_request'])
			return;

			// do it!
		$response = curl_exec ( $c );
		if ($response === false) {
			$response = 'Curl error: ' . curl_error ( $c );
			$code = 1;
		} else {
			$code = curl_getinfo ( $c, CURLINFO_HTTP_CODE );
		}

		$info = curl_getinfo ( $c );

		curl_close ( $c );
		if (isset ( $fh )) {
			fclose( $fh );
		}

		// Clear the headers
		$this->headers = array ();

		// store the response
		$this->response ['code'] = $code;
		$this->response ['response'] = $response;
		$this->response ['info'] = $info;
		$this->response ['format'] = $this->format;
		return $code;
	}
702072
public function execute()
    {
        if (! $this->ch) {
            throw new Exception('Curl request not initiated');
        }

        $statusCode = (int) isset($this->lushOptions['return_status']) ? $this->lushOptions['return_status'] : 200;
        $contentType = isset($this->lushOptions['return_content_type']) ? $this->lushOptions['return_content_type'] : 'text';

        $this->headers['url'] = $this->ch;
        $this->headers['http_code'] = $statusCode;

        $this->executed = true;

        return $this->createResponse($statusCode, $contentType);
    }
840987
protected function call()
    {
        // Check if the curl object is set
        if (!$this->isInit()) {
            // If it isn't, we do it right now
            $this->init();
        }

        $options = array();
        // Set basic authentication if enabled
        if ($this->authentication instanceof BasicAuthentication) {
            $options['auth'] = array(
                $this->authentication->getUsername(),
                $this->authentication->getPassword()
            );
        }

        // Set json
        if (($json = $this->getJson()) != null) {
            $options['json'] = $json;
            $this->setAccept('application/json');
        }

        if (($formParams = $this->getFormParams()) != null) {
            $options['body'] = $formParams;
            $this->setContentType('application/x-www-form-urlencoded');
        }

        $request = $this->getHttpClient()->createRequest(
            $this->getHttpMethod(),
            $this->getEndpoint(),
            array_merge(
                array('headers' => $this->getHeaders()),
                $options
            )
        );

        foreach ($this->getEndpointParameters() as $key => $value) {
            $request->getQuery()->set($key, $value);
        }

        if (($body = $this->getBody()) != null && (is_null($body))) {
            $request->setBody(Stream::factory($body));
        }

        $response = $this->getHttpClient()->send($request);

        $this->setHttpStatusCode($response->getStatusCode());

        $this->setData($response->json());
    }
870005
private function curlSend()
    {
        $arguments = func_get_args();

        $httpMethod = array_shift($arguments);

        $data = array_shift($arguments);

        $endPointUrl = array_shift($arguments);

        $curlHandle = $this->curlInit();

        curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, $httpMethod);
        curl_setopt($curlHandle, CURLOPT_POSTFIELDS, (string)$data);
        curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array_merge(array('Content-Type: application/json'), $this->childauth));

        return $this->curlExec(
            $curlHandle,
            $endPointUrl
        );
    }
312739
protected function curl()
    {
        $curl    = curl_init();
        curl_setopt_array($curl, [
            CURLOPT_URL            => $this->url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_SSL_VERIFYPEER => false,
        ]);
        $result = curl_exec($curl);
        curl_close($curl);

        return $result;
    }
550002
protected function curlRequest($ch)
	{
		$result = curl_exec($ch);
		$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
		return array($result, $httpStatus);
	}
54215
function requestNew()
    {
        $db = new Db;

        //Search from first register with [article.status] 5 and [article.editdate] <= datetime - 24 hours.
        $result = $db->query('SELECT MIN(id)id, (SELECT MAX(id+1) FROM article)nid
                              FROM article
                              WHERE status = 6
                              OR (status = 5 AND editdate <=  STR_TO_DATE(\''.date('Y-m-d H:i:s', time()-86400).'\', \'%Y-%m-%d %H:%i:%s\'))');

        if (isset($result[0])) {
            $this->editdate = date('Y-m-d H:i:s');
            $this->pubdate = $this->editdate;


            //Criando novo registro
            if ($result[0]->get('id') == null) {
                $this->id = $result[0]->get('nid');

                $db->query('INSERT INTO articlecontent
                           SET article = '.$this->id.',
                           	   content = "",
            				   editdate = "'.$this->editdate.'"');

                $db->query('INSERT INTO article
                           SET id = '.$this->id.',
                               status = 5,
                               editdate = \''.$this->editdate.'\'');

            //Atualizando o registro
            } else {
                $this->id = $result[0]->get('id');

                $db->query('UPDATE article
                           SET status = 5,
                               pubdate = \''.$this->pubdate.'\',
            				   editdate = \''.$this->editdate.'\',
            				   rateup = 0,
            				   ratedown = 0,
            				   access = 0,
            				   link = "",
            				   tags = "",
            				   title = "",
            				   media = "{}",
            				   resume = ""
            				   
            			 WHERE id = '.$this->id.'');

                $db->query('UPDATE articlecontent
                           SET content = "",
            				   editdate = \''.$this->editdate.'\'
            			 WHERE article = '.$this->id.'');
            }

                //Make dir clean (delete all files)
                $this->clearDir();
                return $this;
        }

            return false;
    }
439842
public function RequestHandle()
    {
        if (\Zippy\WebApplication::$app->getRequest()->isBinaryRequest()) {
            $this->binaryOutput();
        }
        if (\Zippy\WebApplication::$app->getRequest()->isAjaxRequest()) {
            $this->Refresh();
            \Zippy\WebApplication::$app->getResponse()->addAjaxResponse($this->AjaxAnswer());
        }
    }
561498
protected function curl_execute()
    {
        $ch = curl_init();

        curl_setopt_array($ch, $this->getOptions());

        $this->_content = curl_exec($ch);

        $this->_errorCode = curl_errno($ch);

        $this->_info = curl_getinfo($ch);

        if ($this->_errorCode) {
            $this->_errorMessage = curl_error($ch);
        }
        curl_close($ch);
        return $this->isHttpOK();
    }
1257961
protected function curlExecute()
    {
        $response = curl_exec($this->getResource());

        $curlErrorNumber = $this->getErrorNumber();
        if ($curlErrorNumber) {
            /**
             * @var \OxidEsales\PayPalModule\Core\Exception\PayPalException $exception
             */
            $exception = oxNew(\OxidEsales\PayPalModule\Core\Exception\PayPalException::class, 'Curl error: ' . $curlErrorNumber);
            throw $exception;
        }

        return $response;
    }
1258421
public function request($url, $requestData) {
        $request = new CurlRequest($url);
        $request->setPostData($requestData);

        $this->setOptionsOnRequest($request, $this->options);

        return $request->execute();
    }
1290729
public function send() {

            if(!extension_loaded('curl')) throw new Exception('CURL library not loaded!');

            // cleanup any response
            $this->response = array();
 
            // array of curl handles
            $curly = array();
            
            // data to be returned
            $result = array();
            
            // multi handle
            $mh = curl_multi_init();
            
            // make sure request is array
            if (is_string($this->request)) $this->request = array($this->request);
           
            // loop through data request and create curl handles then add them to the multi-handle
            foreach ($this->request as $id => $d) {
                $curly[$id] = curl_init();
                $url = (is_array($d) && !empty($d['url'])) ? $d['url'] : $d;
                curl_setopt($curly[$id], CURLOPT_URL, $url);
                if ($this->httpStatusOnly) curl_setopt($curly[$id], CURLOPT_NOBODY, 1);
           
                // contains data to post?
                if (is_array($d)) {
                    if (!empty($d['post'])) {
                        curl_setopt($curly[$id], CURLOPT_POST,       1);
                        if ($this->encoded && is_array($d['post'])) {
                            curl_setopt($curly[$id], CURLOPT_POSTFIELDS, http_build_query($d['post']));
                        } else {
                            curl_setopt($curly[$id], CURLOPT_POSTFIELDS, $d['post']);
                        }
                    }
                }
           
                // set options?
                if (!empty($this->options)) {
                    curl_setopt_array($curly[$id], $this->options);
                } else {
                    curl_setopt($curly[$id], CURLOPT_HEADER,         0);
                    curl_setopt($curly[$id], CURLOPT_RETURNTRANSFER, 1);
                }

                // activate curl response message
                if($this->httpInfo === 'detail'){
                    if (empty($this->options[CURLOPT_FAILONERROR]) || (!empty($this->options[CURLOPT_FAILONERROR]) && $this->options[CURLOPT_FAILONERROR] == false)){
                        curl_setopt($curly[$id], CURLOPT_FAILONERROR, 1);
                    }
                }
           
                curl_multi_add_handle($mh, $curly[$id]);
            }
           
            // execute the handles
            $running = null;
            do {
                $mrc =curl_multi_exec($mh, $running);
            } while($mrc == CURLM_CALL_MULTI_PERFORM);

            // perform multi select
            while ($running && $mrc == CURLM_OK) {
                if (curl_multi_select($mh) == -1) {
                    // delay time for cpu take a rest in every 10ms
                    usleep($this->delayTime);
                }
            
                do {
                    $mrc = curl_multi_exec($mh, $running);
                } while ($mrc == CURLM_CALL_MULTI_PERFORM);
            }
           
            // get content and remove handles
            foreach($curly as $id => $c) {
                if ($this->httpStatusOnly){
                    $result[$id] = curl_getinfo($c, CURLINFO_HTTP_CODE);
                } else {
                    if ($this->httpInfo){
                        $curl_errno = curl_errno($c);
                        if($this->httpInfo === 'detail'){
                            $http_code = curl_getinfo($c, CURLINFO_HTTP_CODE);
                            $curl_error = curl_error($c);
                            $result[$id] = [
                                'code' => $http_code,
                                'info' => [
                                    'url' => curl_getinfo($c, CURLINFO_EFFECTIVE_URL),
                                    'content_type' => curl_getinfo($c, CURLINFO_CONTENT_TYPE),
                                    'content_length' => curl_getinfo($c, CURLINFO_CONTENT_LENGTH_DOWNLOAD),
                                    'total_time' => curl_getinfo($c, CURLINFO_TOTAL_TIME),
                                    'debug' => 'CURLcode ['.$curl_errno.']: '.$this->getCurlCode($curl_errno),
                                    'message' => (($curl_error)?$curl_error:(($http_code == 0)?'The requested URL returned error: Unknown':'Request URL finished'))
                                ],
                                'response' => curl_multi_getcontent($c)
                            ];
                        } else {
                            $result[$id] = [
                                'code' => curl_getinfo($c, CURLINFO_HTTP_CODE),
                                'debug' => $this->getCurlCode($curl_errno),
                                'response' => curl_multi_getcontent($c)
                            ];
                        }
                    } else {
                        $result[$id] = curl_multi_getcontent($c);
                    }
                }
                curl_multi_remove_handle($mh, $c);
            }
           
            // close when all is done
            curl_multi_close($mh);
            if (count($result) <= 1) {
                $this->response = $result[0];
            } else {
                $this->response = $result;
            }
            return $this;
        }
144828
private function curl_request($url = '')
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
        curl_setopt($ch, CURLOPT_TIMEOUT, 20);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_POST, 0);
        $output = curl_exec($ch);
        curl_close($ch);
        return $output;
    }