• php代码post请求


    <?php

     

    /**

     * 发送post请求

     * @param string $url 请求地址

     * @param array $post_data post键值对数据

     * @return string

     */

    function send_post($url, $post_data) {

      $postdata = http_build_query($post_data);

      $options = array(

        'http' => array(

          'method' => 'POST',

          'header' => 'Content-type:application/x-www-form-urlencoded,Content-Length: .strlen($query)',

          'content' => $postdata,

          'timeout' => 5 // 超时时间(单位:s)

        )

      );

      $context = stream_context_create($options);

      $result  = file_get_contents($url, false, $context);

      return $result;

    }

     

    //post数据

    $post_data = array(

        'user_id'   => '148206',                                 // 用户ID

        'app_id'    => '85',                                     // 应用ID

        'order_sn'  => 'P201909062014389901',                    // 聚合平台订单号

        'attach'    => '878910012825534479_878910012825534466',  // 游戏订单号

        'money'     => '1',                                      // 订单金额(单位:分)

        'server'    => '3101',                                   // 游戏区服名

        'role'      => 'aaa',                                    // 游戏角色名

        'ip'        => '115.171.217.6',                          // 用户IP

        'add_time'  => '1567772078',                             // 聚合平台订单创建时间

        'sign'      => '1030893470d8e65ee4c4c65359ba6405'        // 签名

    );

     

    $url = 'http://11-1111.11.com:7904/pay_cadd_lesqi';

    $res = send_post($url, $post_data);

    print_r($res);

     

    ?>

  • 相关阅读:
    C语言实例解析精粹学习笔记——31
    进程调度(CFS)
    qemu中 guest与 host 网络配置
    网卡全虚拟化、virtio、vhost-net性能测试
    网桥与TAP设备
    进程调度
    中断、异常和系统调用
    文件系统
    Linux内核内存管理
    QEMU 设备模拟
  • 原文地址:https://www.cnblogs.com/xingchong/p/11482095.html
Copyright © 2020-2023  润新知