char gen pos scrip request 5.0 -m com
本文出至:新太潮流网络博客
- /**
- * [curl以GET的方式访问]
- * @E-mial [email protected]
- * @TIME 2017-04-07
- * @web http://blog.iinu.com.cn
- * @param [data] $url [访问的路径]
- * @param string $data [description]
- * @return [type] [description]
- */
- function curlGet($url, $data = ‘‘) {
- $ch = curl_init();
- $header = "Accept-Charset: utf-8";
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- 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);
- $temp = curl_exec($ch);
- return $temp;
- }
- /**
- * [curl以POST的方式访问]
- * @E-mial [email protected]
- * @TIME 2017-04-07
- * @WEB http://blog.iinu.com.cn
- * @param [data] $url [访问的路径]
- * @param [type] $data [description]
- * @return [type] [description]
- */
- function curlPost($url, $data) {
- $ch = curl_init();
- $header = "Accept-Charset: utf-8";
- 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($curl, CURLOPT_HTTPHEADER, $header);
- 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 false;
- } else {
- return true;
- }
- }
本文出至:新太潮流网络博客
PHP的CURL的POST/GET访问
来源: http://www.bubuko.com/infodetail-2303916.html