projectDir = $projectDir; } public function initCurl(string $url, bool $followLocation = false, $session = 'cookie.txt') { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $followLocation); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['CURLOPT_USERAGENT']); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 30); //curl_setopt($ch, CURLOPT_REFERER, "https://www.baocat.games"); $cookies = '/tmp/' . $session; //tempnam('/tmp', $session); // curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies); // curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies); return $ch; } public function initCurlWithHeaders(string $url, bool $followLocation = false, $session = 'cookie.txt') { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $followLocation); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['CURLOPT_USERAGENT']); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 30); //curl_setopt($ch, CURLOPT_REFERER, "https://www.baocat.games"); $cookies = '/tmp/' . $session; //tempnam('/tmp', $session); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies); return $ch; } public function initCurlPost(string $url, array $postFields = [], $session = 'cookie.txt') { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['CURLOPT_USERAGENT']); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 30); //curl_setopt($ch, CURLOPT_REFERER, "https://www.baocat.games"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); // $cookies = '/tmp/' . $session; //tempnam('/tmp', $session); // curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies); // curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies); return $ch; } }