Php Curl Cookie Çözüm ?
-
Bir siteye curl ile username ve şifre kullanarak giriş yaptırıyorum , fakat tek bir kullancı değil aynı anda ve farklı kullanıcılarda giriş yapacaklar veya veritabanından gelen bilgiyle giriş yapacaklarını farz edelim ve o zaman hepsi cookie.txt içine yazacak, ben her biri için bir klasörde kullanıcı adıyla oluşmuş cookie.txt dosyası oluşturmasını istiyorum. örnek tahribat.txt gibi. Fakat bir çok farklı şekilde denememe rağmen olmadı, post ile yada elle yazarak yada veritabanından gelen kullanıcı adı ile text dosyası oluşturup dosya varmı yokmu kontrolünü yaptırarak denedim yine olmadı. siteye giriş yapıyor ama cookie dosyası her bir kullanıcıya özgü oluşturamıyorum.
$username ='kullaniciadi'; $password ='123456789'; $cookie_path='cerez/'.$username.'.txt'; function SendRequest($url, $post, $post_data, $user_agent, $cookies) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://www.siteismi.com/'.$url); /* curl_setopt($ch, CURLOPT_PROXY, $proxy); curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth); */ curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); if($post) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); } if($cookies) { curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_path); } else { curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_path); } $response = curl_exec($ch); $http = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return array($http, $response); }
TheMayk tarafından 03/Mar/16 15:12 tarihinde düzenlenmiştir
