使用“Guzzle”在PHP中执行异步查询

make an asynchronous query with PHP using Guzzle and not wait for the result.

  • how to retrieve JSON content into another PHP file?

    <?php
           require '/tools/guzzle-master/vendor/autoload.php';
            use GuzzleHttp\Client;
            use GuzzleHttp\Psr7\Request;
            $url = 'https://xxxxxxx/receive.php;
              /*creating a client*/
            $client = new Client();
             /*JSON formatting */
            $param = array(
                'order_id' => 4544,
                'type' => 0,
                'amount' => 1266,
                'fullname' => 'qdxeq',
                'account' => 'dqad',
                'callback_url' => 'http://yuexingy.top/Withdraw/WithdrawCallback.aspx',
                'device_type' => 'dqd',
                'device_id' => 'dafwe',
                'device_ip' => 'dwe',
            );
    
            $json = json_encode($param);//json encoding
            $data = array('json'=>$json);
            $req = new Request('POST',$url, $data);
            //sending the asynchronous request
            $promise = $client->sendAsync($req,['timeout' => 10])->then(function ($response) { 
            echo 'I completed! ' . $response->getBody();
            });
            $promise->wait();
        ?>