首页 > 解决方案 > 执行 HTTP 请求我想将延迟时间从 Laravel 添加到外部 API

问题描述

我想在从 laravel 延迟时间大约 10,20 秒调用我的 api 之前添加一个延迟时间,然后它应该被执行。

我的代码是:

$base_url = 'https://pk.qareeb.com/';
    $api_path = 'rest/all/V1/orders/';

    $arr['searchCriteria']['filterGroups'][0]['filters'][0]['field'] = 'increment_id';
    $arr['searchCriteria']['filterGroups'][0]['filters'][0]['value'] = $payload;
    $arr['searchCriteria']['filterGroups'][0]['filters'][0]['conditionType'] = '=';

    $url = $base_url . $api_path .'?'. http_build_query($arr);

    $client = new Client();

    $headers = [
        'Authorization' => 'Bearer ' . $token,
        'Accept' => 'application/json',
    ];
    $response = $client->request('GET', $url
        , [
            'headers' => $headers
        ]);

    $statusCode = $response->getStatusCode();
    $body = json_decode($response->getBody()->getContents());

我想在客户端调用 api 时添加延迟时间?

标签: laravelrestapiclient-servermagento-2.3

解决方案


推荐阅读