<pre name= "code" class= "PHP" ><? Class curl{/** * Get method * * @param string interface address * @param string endpoint * @param string model name * @param stri
Ng Method Name * @param array parameter * @return JSON */static public function Sendbyget ($host, $data) {$fields _string = ';
if (!empty ($data)) {ksort ($data);
$fuhao = ';
foreach ($data as $k => $v) {$fields _string. = $fuhao. $v;
$fuhao = '/'; } if (!empty ($fields _string)) {$url = $host. '
/'. $fields _string;
else {$url = $host;
} $ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_ipresolve, CURL_IPRESOLVE_V4);
curl_setopt ($ch, Curlopt_header, 0);
curl_setopt ($ch, Curlopt_fresh_connect, 1);
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, Curlopt_timeout, 5);
curl_setopt ($ch, curlopt_http_version, CURL_HTTP_VERSION_1_0);
$str = curl_exec ($ch); $status = Curl_getinfo ($ch, Curlinfo_htTp_code);
Curl_close ($ch);
if ($status = =) {return $str;
else {return false; }/** * Post method * * @param string interface address * @param array parameter * @return JSON/public F
Unction sendbypost ($url, $data, $cookie = ') {$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
if ($cookie) {curl_setopt ($ch, Curlopt_cookie, $cookie);
curl_setopt ($ch, Curlopt_header, 0);
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, Curlopt_post, true);
curl_setopt ($ch, Curlopt_connecttimeout, 120);
curl_setopt ($ch, curlopt_useragent, $_server[' http_user_agent ']);
curl_setopt ($ch, curlopt_http_version, CURL_HTTP_VERSION_1_0);
curl_setopt ($ch, Curlopt_postfields, $data);
$str = curl_exec ($ch); if (Curl_errno ($ch)) {$error = "Curl Error:". Curl_error ($ch). " \ n: ". Date (' y-m-d h:i:s ', Time ())."
\ r \ n ";
File_put_contents (' Curl_post_error.txt ', $error, file_append);
} curl_close ($ch); ReTurn $str; }
}
When you obtain the HTTPS protocol request, you need to add