Initiates curl session for POST method

@param string $url   Relative url for the request
@param array $params Parameters for the request
@return resource
328080
private function initiatePost($url, $params)
    {
        $ch = curl_init($this->host.'/'.$url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authentication: Token ". $this->token));
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
        return $ch;
    }
495387
public static function sendCurl($_url, $_params)
    {
        $Curl                 = curl_init();
        $_params[CURLOPT_URL] = $_url;
        curl_setopt_array($Curl, $_params);

        $CurlOutput = curl_exec($Curl);

        if (curl_errno($Curl)) {
            echo("Remote service error: ".curl_error($Curl).".");
        }

        curl_close($Curl);

        return $CurlOutput;
    }
95045
public function httpRaw($url, $params = null)
    {
        is_array($params) && $params = json_encode($params, JSON_UNESCAPED_UNICODE);
        return $this->parseHttpResult($url, $params, 'raw');
    }
782631
public function get($url, $params = null) {
    $this->params = $params;
    $this->method = 'GET';
    $this->url = $url;

    return $this->request();
  }
853393
protected static function prepareRequest($url, $parameters = [], $headers = [])
    {
        $request = curl_init();

        if ($query = http_build_query($parameters)) {
            $url .= '?'.$query;
        }

        curl_setopt($request, CURLOPT_URL, $url);
        curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($request, CURLINFO_HEADER_OUT, true);
        curl_setopt($request, CURLOPT_SSL_VERIFYPEER, true);

        return $request;
    }
1173181
public function get($url, array $params = [])
    {
       $queryString = '?' . http_build_query($params);

       $url = $url . $queryString;

       $request = new Request(
            $url,
            'GET'
        );

        return $this->send($request);
    }
587622
private function http_post($url,$param,$post_file=false){
		$oCurl = curl_init();
		if(stripos($url,"https://")!==FALSE){
			curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
			curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false);
			curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); //CURL_SSLVERSION_TLSv1
		}
	        if (PHP_VERSION_ID >= 50500 && class_exists('\CURLFile')) {
	            	$is_curlFile = true;
	        } else {
	        	$is_curlFile = false;
	            	if (defined('CURLOPT_SAFE_UPLOAD')) {
	                	curl_setopt($oCurl, CURLOPT_SAFE_UPLOAD, false);
	            	}
	        }
		if (is_string($param)) {
	            	$strPOST = $param;
	        }elseif($post_file) {
	            	if($is_curlFile) {
		                foreach ($param as $key => $val) {
		                    	if (substr($val, 0, 1) == '@') {
		                        	$param[$key] = new \CURLFile(realpath(substr($val,1)));
		                    	}
		                }
	            	}
			$strPOST = $param;
		} else {
			$aPOST = array();
			foreach($param as $key=>$val){
				$aPOST[] = $key."=".urlencode($val);
			}
			$strPOST =  join("&", $aPOST);
		}
		curl_setopt($oCurl, CURLOPT_URL, $url);
		curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );
		curl_setopt($oCurl, CURLOPT_POST,true);
		curl_setopt($oCurl, CURLOPT_POSTFIELDS,$strPOST);
		$sContent = curl_exec($oCurl);
		$aStatus = curl_getinfo($oCurl);
		curl_close($oCurl);
		if(intval($aStatus["http_code"])==200){
			return $sContent;
		}else{
			return false;
		}
	}
105960
public static function fromRequest(
		$method = null,
		$url = null,
		array $params = null
	) {
		$scheme = ( !isset( $_SERVER['HTTPS'] ) || $_SERVER['HTTPS'] != 'on' ) ?
			'http' : 'https';
		$url = ( $url ?: $scheme ) .
			'://' . $_SERVER['SERVER_NAME'] .
			':' .
			$_SERVER['SERVER_PORT'] .
			$_SERVER['REQUEST_URI'];
		$method = $method ?: $_SERVER['REQUEST_METHOD'];

		// We weren't handed any params, so let's find the ones relevant
		// to this request. If you run XML-RPC or similar you should use this
		// to provide your own parsed parameter-list
		if ( !$params ) {
			// Find request headers
			$headers = Util::getHeaders();

			// Parse the query-string to find GET params
			$params = Util::parseParameters( $_SERVER['QUERY_STRING'] );

			// It's a POST request of the proper content-type, so parse POST
			// params and add those overriding any duplicates from GET
			if ( $method === 'POST' &&
				isset( $headers['Content-Type'] ) &&
				strstr( $headers['Content-Type'],
					'application/x-www-form-urlencoded'
				)
			) {
				$post_data = Util::parseParameters(
					file_get_contents( self::$POST_INPUT )
				);
				$params = array_merge( $params, $post_data );
			}

			// We have a Authorization-header with OAuth data. Parse the header
			// and add those overriding any duplicates from GET or POST
			if ( isset( $headers['Authorization'] ) &&
				substr( $headers['Authorization'], 0, 6 ) === 'OAuth '
			) {
				$header_params = Util::splitHeader( $headers['Authorization'] );
				$params = array_merge( $params, $header_params );
			}
		}

		return new Request( $method, $url, $params );
	}
357306
protected function send($url, array $params)
    {
        $success = false;

        $rawResponse = $this->client->post($url, [
            'exceptions'      => false,
            'timeout'         => '80',
            'connect_timeout' => '30',
            'verify'          => true,
            'auth'            => [
                $this->config['client'],
                $this->config['token'],
            ],
            'headers' => [
                'Accept'         => 'application/json',
                'Accept-Charset' => 'utf-8',
                'Content-Type'   => 'application/x-www-form-urlencoded',
            ],
            'body' => $params,
        ]);

        if (substr((string) $rawResponse->getStatusCode(), 0, 1) === '2') {
            $response = json_decode($rawResponse->getBody(), true);
            $success = true;
        } else {
            $response = $this->responseError($rawResponse);
        }

        return $this->mapResponse($success, $response);
    }
764187
public function curlGet($url, array $params = [], array $opts = [])
    {
        $params = $this->params($params);
        $queryStr = http_build_query($params);
        $opts[CURLOPT_POST] = false;
        $opts[CURLOPT_URL] = $queryStr ? "$url?$queryStr" : $url;

        return self::curl($opts);
    }
180293
public function sendRequest($url, $params, $method)
    {
        if($method=='POST')
        {
            if (!empty($params['file']))
                $ch = $this->initiateUpload($url, $params);
            else
                $ch = $this->initiatePost($url, $params);
        }
        else if($method=='GET')
        {
            $ch = $this->initiateGet($url, $params);
        }
        else if($method=='DELETE')
        {
            $ch = $this->initiateDelete($url, $params);
        }
        else{
            throw new \Exception("Method ".$method." not supported!");
        }

        if (! $ret = curl_exec($ch))
        {
            trigger_error(curl_error($ch));
        }

        curl_close($ch);
        return $ret;
    }
1187826
protected function postRequest($url, $parameters = [])
    {
        if (!empty($parameters)) {
            $this->parameters->addPost($parameters);
        }

        return $this->request($url);
    }
945673
public static final function get($url, array $Params = [], array $Headers = [], $flags = 0b0000) {
		$Curl = curl_init();
		if (preg_match('/^(.*):([0-9]+)$/', $url, $Macth) > 0){
			curl_setopt($Curl, CURLOPT_PORT, $Macth[2]);
			$url = $Macth[1];
		}

		if (count($Params) > 0){
			$url .= '?' . http_build_query($Params, '', '&', PHP_QUERY_RFC3986);
		}

		if (count($Headers) > 0){
			curl_setopt($Curl, CURLOPT_HTTPHEADER, Arr::pack($Headers, ': '));
		}

		curl_setopt($Curl, CURLOPT_URL, $url);
		curl_setopt($Curl, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($Curl, CURLOPT_SSL_VERIFYPEER, true);
		curl_setopt($Curl, CURLOPT_SSL_VERIFYHOST, 2);

		if (self::F_RETURN_HEADERS & $flags) {
			curl_setopt($Curl, CURLOPT_HEADER, true);
		}

		if (($Response = curl_exec($Curl)) === false) {
			$Exception = new \Exception(curl_error($Curl), curl_errno($Curl));
			curl_close($Curl);
			throw $Exception;
		}

		curl_close($Curl);
		return $Response;
	}
384926
public function _fetch ($url, $method, $params) {
		if (! extension_loaded ('curl')) {
			$this->error = 'cURL extension not loaded.';
			return false;
		}

		$ch = curl_init ();
		curl_setopt ($ch, CURLOPT_URL, $url);
		curl_setopt ($ch, CURLOPT_MAXREDIRS, 3);
		curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);
		curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt ($ch, CURLOPT_VERBOSE, 0);
		curl_setopt ($ch, CURLOPT_HEADER, 1);
		curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 10);
		curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
		curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);

		/* HTTP Basic Authentication */
		if ($this->user && $this->password) {
			curl_setopt ($ch, CURLOPT_USERPWD, $this->user . ":" . $this->password);	
		}

		if ($this->request_format == 'xml') {
			$this->request_headers = array_merge ($this->request_headers, array ("Expect:", "Content-Type: text/xml", "Length: " . strlen ($params)));
		}
		switch ($method) {
			case 'POST':
				curl_setopt ($ch, CURLOPT_POST, 1);
				curl_setopt ($ch, CURLOPT_POSTFIELDS, $params);
				break;
			case 'DELETE':
				curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
				break;
			case 'PUT':
				curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
				curl_setopt ($ch, CURLOPT_POSTFIELDS, $params);
				break;
			case 'GET':
			default:
				break;
		}

		if (count ($this->request_headers)) {
			curl_setopt ($ch, CURLOPT_HTTPHEADER, $this->request_headers);
		}

		$res = curl_exec ($ch);

		$http_code = curl_getinfo ($ch, CURLINFO_HTTP_CODE);

		// Check HTTP status code for denied access
		if ($http_code == 401) {
			$this->errno = $http_code;
			$this->error = "HTTP Basic: Access denied.";
			curl_close ($ch);
			return false;
		}

		// Check HTTP status code for rate limit
		if ($http_code == 429) {
			if (preg_match ('/Retry-After: ([0-9]+)/', $res, $retry_after)) {
			  sleep(intval($retry_after[1]));
			  return $this->_fetch ($url, $method, $params);
			}
			$this->errno = $http_code;
			$this->error = "Too Many Requests";
			curl_close ($ch);
			return false;
		}

		if (! $res) {
			$this->errno = curl_errno ($ch);
			$this->error = curl_error ($ch);
			curl_close ($ch);
			return false;
		}

		curl_close ($ch);
		return $res;
	}
1249548
public function put(string $url, array $params = [])
    {
        return $this->send('PUT', $url, [
            $this->bodyFormat => $params,
        ]);
    }
705226
public function post($url, $params=array(), $token='', $secret='') {
        return $this->request('POST', $url, $params, $token, $secret);
    }
1280721
protected function send($url, array $params)
    {
        $success = false;

        $rawResponse = $this->client->get($url.'?'.http_build_query($params), [
            'exceptions'      => false,
            'timeout'         => '80',
            'connect_timeout' => '30',
            'headers'         => [
                'Accept'       => 'application/xml',
                'Content-Type' => 'application/x-www-form-urlencoded',
            ],
        ]);

        if ($rawResponse->getStatusCode() == 200) {
            $success = false;
            $response = $this->parse($rawResponse->getBody());

            if (isset($response->error)) {
                $response = $this->responseError($rawResponse);
            } else {
                $success = $response->response->attributes()->type == 'status';
            }
        } else {
            $response = $this->responseError($rawResponse);
        }

        return $this->mapResponse($success, $response);
    }