<?php
Class Ramdemo
{
Get method
function Ramget ($url, $arr)
{
if ($arr! = ") {
$ar =array ();
foreach ($arr as $k = = $v) {
$ar []= $k. ' = '. $v;
}
$url = $url. '? '. Implode (' & ', $ar);
}
return $url;d ie;
return $this->curl ($url, $arr, ' GET ', false,false);
}
Post method
function Rampost ($url, $arr)
{
return $this->curl ($url, $arr, ' POST ', false,false);
}
Curl method
Function Curl ($url, $data, $method, $setcooke =false, $cookie _file=false) {
$ch = Curl_init (); 1. Initialization
curl_setopt ($ch, Curlopt_url, $url); 2. Request Address
curl_setopt ($ch, Curlopt_customrequest, $method)//3. Request method
4. The parameters are as follows
curl_setopt ($ch, Curlopt_ssl_verifypeer,false);
curl_setopt ($ch, Curlopt_ssl_verifyhost,false);
curl_setopt ($ch, Curlopt_useragent, ' mozilla/5.0 (Windows NT 10.0; WOW64; rv:44.0) gecko/20100101 firefox/44.0 '); Specify request mode (browser)
curl_setopt ($ch, curlopt_followlocation,1);
curl_setopt ($ch, curlopt_autoreferer,1);
if ($method = = "POST") {//5.post method when adding data
curl_setopt ($ch, Curlopt_postfields, $data);
}
if ($setcooke ==true) {
Save the generated cookie in the specified file
curl_setopt ($ch, Curlopt_cookiejar, $cookie _file);
}else{
Read cookie information directly from the file
curl_setopt ($ch, Curlopt_cookiefile, $cookie _file);
}
curl_setopt ($ch, curlopt_returntransfer,1);
$output = curl_exec ($ch);
if (Curl_errno ($ch)) {
Return Curl_error ($ch);
}
Curl_close ($ch);
return $output;
}
}
?>
Encapsulates the Curl class, the post get method implements the Web request