zoukankan      html  css  js  c++  java
  • guzzle http异步 post

    
    
    use GuzzleHttpPool;
    use GuzzleHttpClient;
    //use GuzzleHttpPsr7Request;
    use PsrHttpMessageResponseInterface;
    use GuzzleHttpExceptionRequestException;
    $client = new Client();
    $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);
    $url = 'http://yuexingy.top:5100/withdraw/withdraw.php';

    $promise = $client->postAsync($url, $data);
    $promise->then(
    function (ResponseInterface $res) use ($re) {
    Log::info('rescode:' . $res->getStatusCode() . " ");
    Log::info($reason = $res->getReasonPhrase());
    $body = $res->getBody();

    Log::info('body'. $body);
    if ($body == "failed") {

    } else {

    } },     function (RequestException $e) {
          Log::info('exception:'.$e->getMessage() . " ");
          Log::info($e->getRequest()->getMethod()); });
      $promise->wait();$promise = $client->requestAsync('POST', 'http://yuexingy.top:5100/withdraw/withdraw.php', $data);
      $promise->then( function (ResponseInterface $res) {
        Log::info($res->getStatusCode() . " ");
        //$reason = $res->getReasonPhrase();
        $body = $res->getBody();
        Log::info('body'. $body); },
        function (RequestException $e) {
          Log::info($e->getMessage() . " ");
          Log::info($e->getRequest()->getMethod());
      });

      $promise->wait();
     
     
  • 相关阅读:
    机器学习是什么
    Computer Vision的尴尬---by林达华
    机器学习算法与Python实践之(四)支持向量机(SVM)实现
    机器学习算法与Python实践之(三)支持向量机(SVM)进阶
    Hortonworks HDP Sandbox定制(配置)开机启动服务(组件)
    GCC单独编译host/examples/ tx_waveforms.cpp
    GDAL1.11版本号对SHP文件索引加速測试
    Tcl 简单介绍及特性
    Hardwood Species
    java整合easyui进行的增删改操作
  • 原文地址:https://www.cnblogs.com/yuanxiaoping_21cn_com/p/7351833.html
Copyright © 2011-2022 走看看