中文字幕亚洲一区,69久久久久精品9999不卡片,亚洲国产日韩欧美在线看片,国产精品久久久久久久久岛国

龍巖易富通網絡科技有限公司

龍巖小程序開發,龍巖分銷系統

模擬get或post

2016.03.14 | 2233閱讀 | 0條評論 | php

CURL方式:

public function httpCurl($url,$data) {

$curl = curl_init ();

curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, true );

curl_setopt ( $curl, CURLOPT_TIMEOUT, 500 );

curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER, false );

curl_setopt ( $curl, CURLOPT_SSL_VERIFYHOST, false );

curl_setopt ( $curl, CURLOPT_URL, $url );

if (!empty($data))

{

  curl_setopt ( $curl, CURLOPT_POST, 1 );

  curl_setopt ( $curl, CURLOPT_POSTFIELDS, $data );

}

$res = curl_exec ( $curl );

curl_close ( $curl );

return $res;

}




數據流方式:

/**

*Huang Jing

*2016年1月12日 10:51:29

*Http 客戶端   實例

*Post方法

******/


class HttpClient {

  //post方法提交

  public static function post2($url, $data) {  //file_get_content

        $postdata = http_build_query( $data );

        $opts = array('http' =>

                      array(

                          'method'  => 'POST',

                          'header'  => 'Content-type:application/x-www-form-urlencoded;charset=GBK',

                          'content' => $postdata

                      )

        );

 

        $context = stream_context_create($opts);

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

         return  $result;

    }

}


贊 (

發表評論

主站蜘蛛池模板: 曲阜市| 马公市| 龙井市| 略阳县| 华池县| 绥滨县| 渭南市| 垫江县| 崇明县| 竹溪县| 双峰县| 辉县市| 武乡县| 金秀| 乌鲁木齐县| 安阳县| 垣曲县| 芒康县| 汝南县| 盈江县| SHOW| 新竹市| 拉孜县| 麟游县| 和龙市| 鹤峰县| 玉田县| 嵊州市| 义乌市| 蛟河市| 易门县| 苗栗市| 南漳县| 怀集县| 宁蒗| 东丰县| 东乌珠穆沁旗| 当阳市| 广宗县| 中江县| 扬州市|