PHP中CURL实现GET和POST请求
2021-03-12 13:31
阅读:533
标签:tran custom cells dex use comm tab space ber
POST方式实现(推荐)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
function postData( $url , $data ){
$ch = curl_init();
curl_setopt( $ch , CURLOPT_URL, $url );
curl_setopt( $ch , CURLOPT_CUSTOMREQUEST, "POST" );
curl_setopt( $ch , CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt( $ch , CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt( $ch , CURLOPT_USERAGENT, ‘Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)‘ );
curl_setopt( $ch , CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch , CURLOPT_AUTOREFERER, 1);
curl_setopt( $ch , CURLOPT_POSTFIELDS, $data );
curl_setopt( $ch , CURLOPT_RETURNTRANSFER, true);
$tmpInfo = curl_exec( $ch );
if (curl_errno( $ch )) {
return curl_error( $ch );
}
curl_close( $ch );
return $tmpInfo ;
} |
GET方式实现直线导轨滑台
1
2
3
4
5
6
7
8
9
10
11
12
|
function getData( $url ){
$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_FOLLOWLOCATION,1);
curl_setopt( $ch , CURLOPT_SSL_VERIFYPEER,false);
curl_setopt( $ch , CURLOPT_SSL_VERIFYHOST,false);
$result = curl_exec( $ch );
curl_close( $ch );
return $result ;
} |
PHP中CURL实现GET和POST请求
标签:tran custom cells dex use comm tab space ber
原文地址:https://www.cnblogs.com/furuihua/p/12826487.html
文章来自:搜素材网的编程语言模块,转载请注明文章出处。
文章标题:PHP中CURL实现GET和POST请求
文章链接:http://soscw.com/index.php/essay/63704.html
文章标题:PHP中CURL实现GET和POST请求
文章链接:http://soscw.com/index.php/essay/63704.html
评论
亲,登录后才可以留言!