zoukankan      html  css  js  c++  java
  • 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);

     

    ?>

  • 相关阅读:
    eclipse环境:把jdk1.6 改 jdk1.7或jdk1.8(改回也可以)(图文详解)
    SVN 将文件还原到之前的指定版本
    用起来很方便的枚举扩展类
    VS2015新功能
    EasyUi 动态列
    基于EasyUi的快速开发框架
    深圳某保险公司招聘职位列表
    考勤系统之计算工作小时数
    考勤系统之状态管理
    第一次裁员
  • 原文地址:https://www.cnblogs.com/xingchong/p/11482095.html
Copyright © 2011-2022 走看看