douxing2156 2019-07-30 18:12
浏览 291

使用“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();
        ?>
    
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!