通过POST方式发送数据
@param string $url
@param  $post_data
@param  $timeout
@param  $header
@param  $data_type
@return mixed
322768
public static function doPost($url, $post_data = [], $timeout = 5, $header = "", $data_type = "")
    {
        if (empty($url) || empty($post_data) || empty($timeout))
            return false;
        if (!preg_match('/^(http|https)/is', $url))
            $url = "http://" . $url;
        $code = self::getSupport();
        switch ($code) {
            case 1:
                return self::curlPost($url, $post_data, $timeout, $header, $data_type);
                break;
            case 2:
                return self::socketPost($url, $post_data, $timeout, $header, $data_type);
                break;
            case 3:
                return self::phpPost($url, $post_data, $timeout, $header, $data_type);
                break;
            default:
                return false;
        }
    }
415066
public static Post post(String url, byte[] content, int connectTimeout, int readTimeout) {

        try {
            return new Post(url, content, connectTimeout, readTimeout);
        } catch (Exception e) {
            throw new HttpException("Failed URL: " + url, e);
        }
    }
538231
public function post($url, $data = '', array $headers = [])
    {
        return $this->executor->execute(
            $url,
            [
                CURLOPT_POST => true,
                CURLOPT_HTTPHEADER => $headers,
                CURLOPT_POSTFIELDS => $data,
            ]
        );
    }
1243683
public function post($url, $data = [], $params = null)
    {
        foreach ($data as $val) {
            if ($val instanceof UploadFile) {
                $params['contentType'] = 'multipart/form-data';
            }
        }
        if (!isset($params['contentType'])) {
            $params['contentType'] = 'application/x-www-form-urlencoded';
        }
        if ($params['contentType'] === 'application/x-www-form-urlencoded') {
            $body = http_build_query($data, '', '&', PHP_QUERY_RFC3986);
        } elseif ($params['contentType'] === 'application/x-json' || $params['contentType'] === 'application/json') {
            $body = json_encode($data);
        } else {
            $body = 'Unsupported Content-Type';
        }
        if (!isset($params['headers'])) {
            $params['headers'] = [];
        }
        $params['headers']['Content-Length'] = mb_orig_strlen($body);
        $this->sendRequestHeaders('POST', $url, $params);
        $this->write($body);
        $this->writeln('');
    }
1339724
function (url, data, timeout) {

   log.debug("new http_post request", url, data, timeout);

   var d = when.defer();
   var req = new XMLHttpRequest();
   req.withCredentials = true; // pass along cookies
   req.onreadystatechange = function () {

      if (req.readyState === 4) {

         // Normalize IE's response to HTTP 204 when Win error 1223.
         // http://stackoverflow.com/a/10047236/884770
         //
         var status = (req.status === 1223) ? 204 : req.status;

         if (status === 200) {

            // response with content
            //
            d.resolve(req.responseText);

         } if (status === 204) {

            // empty response
            //
            d.resolve();

         } else {

            // anything else is a fail
            //
            var statusText = null;
            try {
               statusText = req.statusText;
            } catch (e) {
               // IE8 fucks up on this
            }
            d.reject({code: status, text: statusText});
         }
      }
   }

   req.open("POST", url, true);
   req.setRequestHeader("Content-type", "application/json; charset=utf-8");

   if (timeout > 0) {
      req.timeout = timeout; // request timeout in ms

      req.ontimeout = function () {
         d.reject({code: 501, text: "request timeout"});
      }
   }

   if (data) {
      req.send(data);
   } else {
      req.send();
   }

   if (d.promise.then) {
      // whenjs has the actual user promise in an attribute
      return d.promise;
   } else {
      return d;
   }
}
535681
static function CurlPut($url, $data, $verify_cert = false, $timeout = 30)
	{
		return HttpRequest::CurlRequest("PUT",$url, $data, $verify_cert, $timeout);
	}
863636
public static String doPost(String url, String ctype, byte[] content, int connectTimeout, int readTimeout) throws IOException {
        return _doPost(url, ctype, content, connectTimeout, readTimeout, null);
    }
319623
protected function request($url, $data, $timeoutMs = 3000) {
        $options = array(
            CURLOPT_URL                 => $url,
            CURLOPT_RETURNTRANSFER      => TRUE,
            CURLOPT_HEADER              => 0,
            CURLOPT_CONNECTTIMEOUT_MS   => $timeoutMs,
            CURLOPT_HTTPHEADER          => $this->getHeaders(),
        );

        if (!empty($data)) {
            $options[CURLOPT_POST]          = 1;
            $options[CURLOPT_POSTFIELDS]    = $data;
        }
        
        $options = $this->option + $options; //$this->>option优先
        
        $ch = curl_init();
        curl_setopt_array($ch, $options);
        $curRetryTimes = $this->retryTimes;
        do {
            $rs = curl_exec($ch);
            $curRetryTimes--;
        } while ($rs === FALSE && $curRetryTimes >= 0);
        $errno = curl_errno($ch);
        if ($errno) {
            throw new InternalServerErrorException(sprintf("%s::%s(%d)\n", $url, curl_error($ch), $errno));
        }

        //update cookie
        if ($this->hascookie) {
            $cookie = $this->getRetCookie(curl_getinfo($ch, CURLINFO_COOKIELIST));
            !empty($cookie) && $this->cookie = $cookie + $this->cookie;
            $this->hascookie = FALSE;
            unset($this->header['Cookie']);
            unset($this->option[CURLOPT_COOKIEFILE]);
        }
        curl_close($ch);

        return $rs;
    }
207504
function get($url, $ip = null, $timeout = 5)
    {
        // set url to post to
        curl_setopt($this->ch, CURLOPT_URL, $url);
        //set method to get
        curl_setopt($this->ch, CURLOPT_HTTPGET, true);
        // return into a variable rather than displaying it
        curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);

        if (empty($this->reqHeader['User-Agent']))
        {
            curl_setopt($this->ch, CURLOPT_USERAGENT, $this->userAgent);
        }
        $this->url = $url;
        //bind to specific ip address if it is sent trough arguments
        if ($ip)
        {
            if ($this->debug)
            {
                echo "Binding to ip $ip\n";
            }
            curl_setopt($this->ch, CURLOPT_INTERFACE, $ip);
        }

        //set curl function timeout to $timeout
        curl_setopt($this->ch, CURLOPT_TIMEOUT, $timeout);
        return $this->execute();
    }
685467
public static function put($url, $data, $httpHeaders = array())
    {
        $ch = self::init($url, $httpHeaders);
        //set the request type
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

        return self::processRequest($ch);
    }
574046
public function post($url=NULL, $postdata=NULL) {
		/* Do note that that if you are going to POST JSON you need to set the
		 * content-type of the transfer AFTER you set the postfields, this is done
		 * if you provide the postdata here, if not, take care to do it or the
		 * content-type will be wrong */
		$curl = curl_init();
		curl_setopt($curl, CURLOPT_FAILONERROR, FALSE);
		curl_setopt($curl, CURLOPT_FOLLOWLOCATION, FALSE);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
		curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
		curl_setopt($curl, CURLOPT_TIMEOUT, 30);
		curl_setopt($curl, CURLOPT_PORT, $this->api_port);

		if($this->api_is_https) {
			if(@CURLOPT_PROTOCOLS != 'CURLOPT_PROTOCOLS') {
				curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
			}
			curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
			curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, TRUE);
		} else {
			if(@CURLOPT_PROTOCOLS != 'CURLOPT_PROTOCOLS') {
				curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP);
			}
		}
		if(isset($postdata)) {
			curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
		}
		curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8'));
		curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
		curl_setopt($curl, CURLOPT_URL, $url);

		$body = curl_exec($curl);
		if($body === FALSE) {
			$error = curl_error($curl);
			if($error === NULL) {
				$error = 'Failed to connect to the Trusly API';
			}
			throw new Trustly_ConnectionException($error);
		}

		if($this->api_is_https) {
			$ssl_result = curl_getinfo($curl, CURLINFO_SSL_VERIFYRESULT);
			if($ssl_result !== 0) {

				$curl_x509_errors = array(
					'0' => 'X509_V_OK',
					'2' => 'X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT',
					'3' => 'X509_V_ERR_UNABLE_TO_GET_CRL',
					'4' => 'X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE',
					'5' => 'X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE',
					'6' => 'X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY',
					'7' => 'X509_V_ERR_CERT_SIGNATURE_FAILURE',
					'8' => 'X509_V_ERR_CRL_SIGNATURE_FAILURE',
					'9' => 'X509_V_ERR_CERT_NOT_YET_VALID',
					'10' => 'X509_V_ERR_CERT_HAS_EXPIRED',
					'11' => 'X509_V_ERR_CRL_NOT_YET_VALID',
					'12' => 'X509_V_ERR_CRL_HAS_EXPIRED',
					'13' => 'X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD',
					'14' => 'X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD',
					'15' => 'X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD',
					'16' => 'X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD',
					'17' => 'X509_V_ERR_OUT_OF_MEM',
					'18' => 'X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT',
					'19' => 'X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN',
					'20' => 'X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY',
					'21' => 'X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE',
					'22' => 'X509_V_ERR_CERT_CHAIN_TOO_LONG',
					'23' => 'X509_V_ERR_CERT_REVOKED',
					'24' => 'X509_V_ERR_INVALID_CA',
					'25' => 'X509_V_ERR_PATH_LENGTH_EXCEEDED',
					'26' => 'X509_V_ERR_INVALID_PURPOSE',
					'27' => 'X509_V_ERR_CERT_UNTRUSTED',
					'28' => 'X509_V_ERR_CERT_REJECTED',
					'29' => 'X509_V_ERR_SUBJECT_ISSUER_MISMATCH',
					'30' => 'X509_V_ERR_AKID_SKID_MISMATCH',
					'31' => 'X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH',
					'32' => 'X509_V_ERR_KEYUSAGE_NO_CERTSIGN',
					'50' => 'X509_V_ERR_APPLICATION_VERIFICATION'
				);

				$ssl_error_str = null;
				if(isset($curl_x509_errors[$ssl_result])) {
					$ssl_error_str = $curl_x509_errors[$ssl_result];
				}

				$error = 'Failed to connect to the Trusly API. SSL Verification error #' . $ssl_result . ($ssl_error_str?': ' . $ssl_error_str:'');
				throw new Trustly_ConnectionException($error);
			}
		}
		$response_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);

		return array($body, $response_code);
	}
308682
public static String doPost(String url, Map<String, String> params, int connectTimeout, int readTimeout) throws IOException {
        return doPost(url, params, DEFAULT_CHARSET, connectTimeout, readTimeout);
    }
752475
public static function getCurlData($url,$type="get",$data=array(),$timeout = 10){
            //对空格进行转义
            $url = str_replace(' ','+',$url);
			if($type == "get"){
				if(!empty($data) && is_array($data)){
					
					$arr = [];
					foreach($data as $k=>$v){
						$arr[] = $k."=".$v;
					}
					$str  = implode("&",$arr);
					if(strstr($url,"?")){
						$url .= "&".$str;
					}else{
						$url .= "?".$str;
					}
				}
				
			}
			$data = json_encode($data);
			$url = urldecode($url);
			//echo $url ;exit;
            $ch = curl_init();
            //设置选项，包括URL
            curl_setopt($ch, CURLOPT_URL, "$url");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch,CURLOPT_TIMEOUT,$timeout);  //定义超时3秒钟  
            if($type == "post"){
				// POST数据
				curl_setopt($ch, CURLOPT_POST, 1);
				curl_setopt($ch, 
					CURLOPT_HTTPHEADER, 
					[
					'Accept: application/json',
					'Content-Type: application/json',
					'Content-Length: ' . strlen($data)
					]
					);

				// 把post的变量加上
				curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
            }
			//执行并获取url地址的内容
            $output = curl_exec($ch);
            //echo $output ;
            //释放curl句柄
            curl_close($ch);
			//var_dump($output);exit;
            return $output;
        
    }
843434
public static String doPost(String url, Map<String, String> header, Map<String, String> param)
            throws KeyManagementException, NoSuchAlgorithmException, IOException {

        String result = null;
        HttpClient httpClient = new SSLClient();
        httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, Constant.DEFAULT_CONN_TIMEOUT);
        httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, Constant.DEFAULT_READ_TIMEOUT);
        HttpPost httpPost = new HttpPost(url);
        // 设置Header
        if (header != null) {
            Set<String> keys = header.keySet();
            for (String key : keys) httpPost.setHeader(key, header.get(key));
        }
        //设置参数
        List<NameValuePair> list = new ArrayList<NameValuePair>();
        Iterator iterator = param.entrySet().iterator();
        while (iterator.hasNext()) {
            Entry<String, String> elem = (Entry<String, String>) iterator.next();
            list.add(new BasicNameValuePair(elem.getKey(), elem.getValue()));
        }
        if (list.size() > 0) {
            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list, Constant.DEFAULT_CHARSET);
            httpPost.setEntity(entity);
        }
        HttpResponse response = httpClient.execute(httpPost);
        if (response != null) {
            HttpEntity resEntity = response.getEntity();
            if (resEntity != null) {
                result = EntityUtils.toString(resEntity, Constant.DEFAULT_CHARSET);
            }
        }
        return result;
    }
619157
public function location(String $url = NULL, Int $time = 0, Array $data = NULL, Bool $exit = true, $type = 'location')
    {
        return Response::redirect($url, $time, $data, $exit, $type);
    }
1088705
function postProtected(url, data, callback) {
    post(url, data, callback, () => {
        setTimeout(
            postProtected.bind(null, url, data, callback),
            1500
        );
    });
}
191103
public function post(string $url, $data, array $headers = [])
    {
        if (is_array($data)) {
            $headers['Content-type'] = self::FORM_CONTENT_TYPE;
        }

        $ctx = $this->getContext('POST', $data, $headers);
        $response = file_get_contents($url, false, $ctx);
        $this->saveCookies($http_response_header);

        return $response;
    }