php guzzle post async
Posted yuanxiaoping_21cn_com
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php guzzle post async相关的知识,希望对你有一定的参考价值。
use GuzzleHttp\Pool;
use GuzzleHttp\Client;
//use GuzzleHttp\Psr7\Request;
use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Exception\RequestException;
$param = array(
‘order_id‘ => $orderId,
‘type‘ => 0,
‘amount‘ => ($re->Amount - $re->Tax) / 100,
‘fullname‘ => $u->BindAlipayName,
‘account‘ => $u->BindAlipay,
‘callback_url‘ => ‘http://yuexingy.top/Withdraw/WithdrawCallback.aspx‘,
‘device_type‘ => $re->DeviceType,
‘device_id‘ => $re->DeviceID,
‘device_ip‘ => $re->DeviceIP,
);
$json = json_encode($param);
$sign = md5($json . time() . "a3fae542929247e9ada6c182cbe57756");
Log::info(‘sign:‘ . $sign);
Log::info(‘$json:‘ . $json);
$data = array(‘json‘=>$json);
//$data = [‘form_params‘=>$param];
//$data = [‘json‘=>$param];
//$data = [‘_token‘=>‘FOkSQwyE9spYsYehn12hxqactJ4fPOCSLsZx4tEf‘, ‘ids‘=>‘995232‘];
$url = ‘http://yuexingy.top:5100/withdraw/withdraw.php‘;
// 发送一个异步请求
$req = new \GuzzleHttp\Psr7\Request(‘POST‘, ‘http://yuexingy.top:5100/withdraw/withdraw.php‘, $data);
$promise = $client->sendAsync($req)->then(function ($response) {
Log::info(‘I completed! ‘ . $response->getBody());
});
$promise->wait();
以上是关于php guzzle post async的主要内容,如果未能解决你的问题,请参考以下文章