国产精品7777777,国产亚洲第一页,亚洲激情网,三级黄色在线免费观看,91男生福利,91男生福利,亚洲天堂福利

龍巖易富通網(wǎng)絡(luò)科技有限公司

龍巖小程序開(kāi)發(fā),龍巖分銷(xiāo)系統(tǒng)

模擬get或post

2016.03.14 | 2815閱讀 | 0條評(píng)論 | 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;

}




數(shù)據(jù)流方式:

/**

*Huang Jing

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

*Http 客戶(hù)端   實(shí)例

*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;

    }

}


贊 (

發(fā)表評(píng)論

永靖县| 嵩明县| 金华市| 丹东市| 苏尼特左旗| 丘北县| 淳化县| 萍乡市| 绍兴市| 巫山县| 炎陵县| 宜宾市| 江津市| 鄂州市| 长岭县| 桃江县| 兴文县| 塔河县| 深泽县| 莎车县| 泾川县| 景德镇市| 侯马市| 闽清县| 资源县| 万载县| 江津市| 义乌市| 海安县| 北川| 高安市| 渭南市| 江西省| 青神县| 凤冈县| 全南县| 仲巴县| 皮山县| 张家口市| 东乡县| 资阳市|