zoukankan      html  css  js  c++  java
  • curl json方式提交

    function assistant_request($url , $params = array()){
            $data_string = json_encode($params,JSON_UNESCAPED_UNICODE);
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
            curl_setopt(
                $ch, CURLOPT_HTTPHEADER,
                array(
                    'Content-Type: application/json'
                )
            );
    
            $data = curl_exec($ch);
            curl_close($ch);
            return ($data);
        }
  • 相关阅读:
    蟠桃记
    考新郎
    有假币
    年会抽奖
    发邮件
    进制回文数
    数位和
    外星人的语言
    一的个数
    继承
  • 原文地址:https://www.cnblogs.com/sisl/p/15472018.html
Copyright © 2011-2022 走看看