webman 有封装好的请求第三方url的方法吗

gaomaoxian

问题描述

我看vendor里有 Illuminate\Support\Facades\Http;
但是 use Illuminate\Support\Facades\Http后使用报错啦

为此你搜索到了哪些方案及不适用的原因

有推荐的吗

876 2 0
2个回答

Noah

guzzle

无法埋名
private function createClientPoolD($urls, $method)
    {
        $this->totalPageCount = count($urls);

        $client = new Client();

        $requests = function ($urls) use ($client,$method) {
            foreach ($urls as $url){
                //print_r($url['options']);
                yield function () use ($url,$client,$method){
                    return $client->requestAsync($method, $url['url'], $url['options']);
                };
            }
        };
        $pool = new Pool($client, $requests($urls), [
            'concurrency' => 100,
            'fulfilled' => function ($response, $index) {
                $this->successHandel($response, $index);
            },
            'rejected' => function ($reason, $index) {
                $this->rejectHandel($reason, $index);
            },
        ]);

        return $pool;
    }
  • 暂无评论
×
🔝