This commit is contained in:
xl
2023-11-14 12:39:28 +08:00
parent c3326a9b5a
commit f92fdab692
15 changed files with 245 additions and 272 deletions
+22 -20
View File
@@ -18,9 +18,6 @@ abstract class Multiprogramming implements Progaram
protected string $errorMsg = '';
protected string $host = 'api.weixin.qq.com';
/**
* @var AppConfig
*/
@@ -87,49 +84,54 @@ abstract class Multiprogramming implements Progaram
/**
* @param string $host
* @param string $requestUrl
* @param mixed $body
* @param string $contentType
* @return Result
*/
protected function post(string $requestUrl, mixed $body, string $contentType = 'application/application'): Result
protected function post(string $host, string $requestUrl, mixed $body, string $contentType = 'application/application'): Result
{
return $this->request('post', $requestUrl, $body, $contentType);
return $this->request($host, 'post', $requestUrl, $body, $contentType);
}
/**
* @param string $host
* @param string $requestUrl
* @param mixed $body
* @param string $contentType
* @return Result
*/
protected function get(string $host, string $requestUrl, mixed $body, string $contentType = 'application/application'): Result
{
return $this->request($host, 'get', $requestUrl, $body, $contentType);
}
/**
* @param string $host
* @param string $requestUrl
* @param mixed $body
* @return Result
*/
protected function get(string $requestUrl, mixed $body, string $contentType = 'application/application'): Result
protected function upload(string $host, string $requestUrl, mixed $body): Result
{
return $this->request('get', $requestUrl, $body, $contentType);
}
/**
* @param string $requestUrl
* @param mixed $body
* @return Result
*/
protected function upload(string $requestUrl, mixed $body): Result
{
return $this->request('upload', $requestUrl, $body);
return $this->request($host, 'upload', $requestUrl, $body);
}
/**
* @param string $host
* @param string $method
* @param string $requestUrl
* @param $body
* @param string $contentType
* @return Result
*/
private function request(string $method, string $requestUrl, $body, string $contentType = 'application/application'): Result
private function request(string $host, string $method, string $requestUrl, $body, string $contentType = 'application/application'): Result
{
$client = new Client($this->host, 443, true);
$client = new Client($host, 80, true);
$proxyHost = $this->payConfig->getProxyHost();
$proxyPort = $this->payConfig->getProxyPort();
if (!empty($proxyHost) && $proxyPort > 0) {