Http协议调用微信接口方法
@param $url api地址
@param $params 参数
@param string $type 提交类型
@return bool|mixed
@throws \yii\base\InvalidParamException
162693
protected function http($url, $params = null, $type = 'get')
    {
        $curl = curl_init();
        switch ($type) {
            case 'get':
                is_array($params) && $params = http_build_query($params);
                !empty($params) && $url .= (stripos($url, '?') === false ? '?' : '&') . $params;
                break;
            case 'post':
                curl_setopt($curl, CURLOPT_POST, true);
                if (!is_array($params)) {
                    throw new InvalidParamException("Post data must be an array.");
                }
                curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
                break;
            case 'raw':
                curl_setopt($curl, CURLOPT_POST, true);
                if (is_array($params)) {
                    throw new InvalidParamException("Post raw data must not be an array.");
                }
                curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
                break;
            default:
                throw new InvalidParamException("Invalid http type '{$type}.' called.");
        }
        if (stripos($url, "https://") !== false) {
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
            curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); // 微信官方屏蔽了ssl2和ssl3, 启用更高级的ssl
        }
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $content = curl_exec($curl);
        $status = curl_getinfo($curl);
        curl_close($curl);
        if (isset($status['http_code']) && intval($status['http_code']) == 200) {
            return $content;
        }
        return false;
    }
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;
        
    }
1209618
public function postUrlEncoded($url, array $params)
    {
        $request = new Request(
            $url,
            'POST',
            'php://temp',
            ['content-type' => 'application/x-www-form-urlencoded']
        );

        $request->getBody()->write(http_build_query($params));
        return $this->send($request);
    }
1370532
public function encodeParameter($type, $param)
    {
        if (!is_string($type)) {
            throw new InvalidArgumentException('The type to encodeParameter must be string.');
        }
        return $this->encodeParameters([$type], [$param]);
    }
436849
protected function createRequest($type, $url, $token)
    {
        return $this->client->createRequest($type, $url, $this->getDefaultHeaders($token));
    }
1216177
protected function request($path, $params = [], $type = 'GET')
    {
        $path = 'sms/' . $path;

        // default params
        if (empty($this->config[ 'serverIp' ])) {
            throw new \InvalidArgumentException('RajaSMS: Server Ip Address is not set!');
        }

        if (empty($this->config[ 'apiKey' ])) {
            throw new \InvalidArgumentException('RajaSMS: API Key is not set');
        } else {
            $params[ 'apikey' ] = $this->config[ 'apiKey' ];
        }

        if ( ! empty($this->config[ 'callbackUrl' ]) and isset($params[ 'datapacket' ])) {
            $params[ 'callbackurl' ] = $this->config[ 'callbackUrl' ];
        }

        $uri = (new Uri($this->config[ 'serverIp' ]))->withPath($path);

        $request = new Curl\Request();

        $request->setConnectionTimeout(500);

        switch ($type) {
            default:
            case 'GET':
                $this->response = $request->setUri($uri)->get($params);
                break;

            case 'POST':
                $request->addHeader('content-type', 'application/json');
                $this->response = $request->setUri($uri)->post($params, 'JSON');
                break;
        }

        if (false !== ($error = $this->response->getError())) {
            $this->addError($error->code, $error->message);
        } elseif ($body = $this->response->getBody()) {
            return $body;
        }

        return false;
    }
13013
private function invalidScalarParameterException(\ReflectionFunctionAbstract $controller, RequestParam $annotation, string $type) : HttpBadRequestException
    {
        return new HttpBadRequestException(sprintf(
            '%s() received an invalid %s value for %s parameter "%s" (bound to $%s).',
            $this->reflectionTools->getFunctionName($controller),
            $type,
            $annotation->getParameterType(),
            $annotation->getName(),
            $annotation->getBindTo()
        ));
    }
595368
public function get($url, $params = array())
    {
        $request = $this->provider->request($url, $params);
        $response = $this->client->send($request);

        $data = $response->getBody()->getContents();
        $format = $this->getFormat($params, $response);

        return $this->serializer->deserialize($data, null, $format);
    }
1022503
public function parameterTypeCheck($param, string $type = 'string'): bool
    {
        $type = 'is_'.$type;

        return (bool) ($type($param) && ! empty($param));
    }
1236780
public static function getRequestParams($type = 'all')
    {
        $request = Yii::$app->getRequest();
        switch ($type) {
            case 'get':
                $params = $request->get();
                break;

            case 'post':
                $params = $request->post();
                break;

            case 'all':
            default:
                $params = ArrayHelper::merge($request->get(), $request->post());
                break;
        }

        return $params;
    }
598271
private function initRequestParams($type, $params)
	{

		$list = self::$customParams;
		if (!isset($list[$type])) {
			throw new GatewayException('Undefined request type');
		}

		$list = $list[$type];
		$requestParams = array();

		foreach ($list as $key) {
			if (!empty($params[$key])) {
				$requestParams[$key] = trim($params[$key]);
			}
		}

		foreach (Config::getAll() as $key => $value) {
			if(
				in_array($type, array('complete', 'refund')) &&
				in_array($key, array('callbackUrl', 'callbackEmail', 'shopUrl'))
			){
				continue;
			}
			$requestParams[$key] = $value;
		}

		$requestParams = $this->convert($requestParams);

		if($type !== 'callback'){
			$requestParams['time'] = time();
		}

		$requestParams['sign'] = $this->sign($type, $requestParams);

		return $requestParams;

	}
1280197
public function get_endpoint_url($type) {
        $endpoint = endpoint::get_record([
            'issuerid' => $this->get('id'),
            'name' => $type . '_endpoint'
        ]);

        if ($endpoint) {
            return $endpoint->get('url');
        }
        return false;
    }
636715
static public function jiraGet($url, $user, array $parameterList = [])
    {
        return self::json(
            $url,
            $parameterList,
            self::HTTP_METHOD_GET,
            [
                'Authorization: Basic ' . $user
            ]
        );
    }
1230667
public function param($param, $value, $type = null)
    {
        return $this->setParameter($param, $value, $type);
    }
1364271
public function sendFile($params, $type, $multipart = false)
    {
        return $this->sendRequest('send'.ucfirst($type), $params, $multipart);
    }
263137
public function osmType(string $type): self
    {
        if (\in_array($type, $this->osmType, true)) {
            $this->query['osm_type'] = $type;

            return $this;
        }

        throw new InvalidParameterException('OSM Type is not supported');
    }
121463
public function getUrl($type, $path, $params = array()) {
        $url = self::$URL_TABLE[$type] . $path;
        if (!empty($params)) {
            $url .= '?' . http_build_query($params);
        }
        return $url;
    }