• Thinkphp POST raw 传值


    //在Common/function 添加此函数

    function curls($url, $data_string) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'X-AjaxPro-Method:ShowList',
    'Content-Type: application/json; charset=utf-8',
    'Content-Length: ' . strlen($data_string))
    );
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
    }

    //在Controller 里面直接调用

    public function test()

    {

      $url = "http://www.xxxx.com";

       $data = array(xxxxxxx);

     $info = curls($url,$data);

      var_dump($info);

    }

  • 相关阅读:
    if语句
    操作列表
    列表
    数据类型(不全)
    windows安装mysql
    hadr启动报错码
    db2主备hadr部署
    java--遍历字符个数
    java--装饰类
    java--继承&接口
  • 原文地址:https://www.cnblogs.com/leaf-cq/p/8509898.html
Copyright © 2020-2023  润新知