Skip to content

Instantly share code, notes, and snippets.

@fazaio
Created October 19, 2020 07:56
Show Gist options
  • Save fazaio/c4ba7ff056809e84a42b5adc635cb543 to your computer and use it in GitHub Desktop.
Save fazaio/c4ba7ff056809e84a42b5adc635cb543 to your computer and use it in GitHub Desktop.
Curl Function PHP
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
// ----------------------------------------------------------
//
// format function curl($url,$pos,$cookie,$body,$head,$sock)
//
// ----------------------------------------------------------
function curl($url,$pos,$cookie,$body,$head,$sock){
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:61.0) Gecko/20100101 Firefox/61.0");
curl_setopt($ch, CURLOPT_HEADER, $head);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
//curl_setopt($ch, CURLOPT_PROXY, $sock);
//curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($ch, CURLOPT_NOBODY, $body);
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $pos);
$result = curl_exec($ch);
curl_close($ch);
return $result;
};
function save($name,$res){
$berkas =fopen($name,"a");
fputs($berkas, $res);
fclose($berkas);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment