国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

HttpClient的問題

anxin

問題描述

參考文檔
http://www.wtbis.cn/doc/workerman/components/workerman-http-client.html
協(xié)程用法
協(xié)程用法需要workerman>=5.0,workerman/http-client>=2.0.0 并安裝 composer require revolt/event-loop

程序代碼

    public static function request($cmd, $postData)
    {
        foreach ($postData as $index => $postDatum) {
            if ($postDatum == '') {
                unset($postData[$index]);
            }
        }

        $reqBean = [
            'orgId' => config('pay.tq.appid'),
            'reqData' => $postData,
            'reqId' => session_create_id(),
            'signType' => 'RSA',
            'timestamp' => date('ymdHis', time()),
            'version' => '1.0',
        ];
        $sign = self::generateSign($reqBean);
        $reqBean['sign'] = $sign;
        $client = new Client();

        try {
            $apiUrl = config('pay.tq.api') . $cmd;
            $response = $client->post($apiUrl, $reqBean);
            if ($response->getStatusCode() !== 200) {
                debug_log('狀態(tài)不對', $reqBean, $response->getStatusCode(), 'tq');
                throw new BusinessException('EQT-ServerStatus響應(yīng)錯誤');
            }
            $content = json_decode($response->getBody()->getContents(), true);
            if ($content['bizCode'] !== '0000') {
                debug_log($cmd, $reqBean, $content, 'tq');
                throw new BusinessException($cmd . '@' . $content['bizMsg']);
            }
            return $content;
        } catch (\Throwable $e) {
            debug_log($cmd, $reqBean, $e->getMessage(), 'tq');
            throw new BusinessException($e->getMessage());
        }

    }

報錯信息

Call to a member function getStatusCode() on null

操作系統(tǒng)及workerman/webman等框架組件具體版本

debian12 和 windows11/10都試了
截圖

在config/process.php
截圖

610 1 0
1個回答

walkor 打賞

加一句

$worker->eventLoop = \Workerman\Events\Fiber::class;
  • anxin 2025-02-08

    這個加到什么位置呢,在webman里邊使用

  • walkor 2025-02-08

    config/process.php

  • anxin 2025-02-08

    只能用\Workerman\Events\Fiber::class 嗎? 用SWOW和http-client不行?

  • walkor 2025-02-08

    可以,要用最新的v3 http-client版本

  • anxin 2025-02-08

    Fatal error: [Fatal error in R8] Cannot declare class Workerman\Coroutine, because the name is already in use
    Stack trace:

    0 D:\webman\webman-pay-api\vendor\composer\ClassLoader.php(576): include()

    1 D:\webman\webman-pay-api\vendor\composer\ClassLoader.php(427): Composer\Autoload{closure}('D:\webman\webma...')

    2 D:\webman\webman-pay-api\vendor\workerman\http-client\src\Client.php(77): Composer\Autoload\ClassLoader->loadClass('Workerman\Corou...')

    3 D:\webman\webman-pay-api\vendor\workerman\http-client\src\Client.php(153): Workerman\Http\Client->request('https://openapi...', Array)

  • anxin 2025-02-08

    我把http-client升級到3.0以上了, 然后就報這個錯

  • walkor 2025-02-08

    更新到3.0.1試下

  • anxin 2025-02-08

    更新到3.0.1之后又是這個 Call to a member function getStatusCode() on null

  • walkor 2025-02-08

    更新到3.0.2

  • anxin 2025-02-08

    發(fā)起請求是可以了, 但是對方收不到數(shù)據(jù), 用guzzle沒問題,我再看看

??