zoukankan      html  css  js  c++  java
  • php 用 http post方法传输数据

    private function http_post($url,$post,$timeout){
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_URL, $url);
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
            curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            $output = curl_exec($curl);
            $code  = curl_getinfo($curl, CURLINFO_HTTP_CODE);
            $errMsg= curl_multi_getcontent($curl);
            curl_close($curl);
    
            if($code != 200) {
                $arrRet = array(
                    'code'    => 1,
                    'err_msg' => $code,
                    'data'    => $errMsg,
                );
                return $arrRet;
            }
    
            $arrRet = array(
                'code'    => 0,
                'err_msg' => $code,
                'data'    => json_decode($output,true),
            );
            return $arrRet;
        }
    $ret = self::http_post('url', $arrInput, 2);
  • 相关阅读:
    js练习 导航栏下拉子菜单
    js练习 DIV做下拉列表
    js添加事件
    HTML5音频和视频
    HTML5表单元素拓展
    document对象
    DOM
    函数
    常用的函数及递归
    JavaScript数组示例
  • 原文地址:https://www.cnblogs.com/tf-Y/p/5777699.html
Copyright © 2011-2022 走看看