Merhaba; Curl kullanarak gmaile login olma çabasındayım. chmod 777 olarak /var/www dizini altında cookies.txt dosyamı hazırladım. Kodu yazdım ancak headerdan okuduğuma göre 302 hatası alıyorum ve gmail beni login sayfasına geri gönderiyor. Cookieler ile ilgili birşeyi atlıyorum ama bulamadım yardımınızı rica ediyorum. Kodum şöyle:
<?php $url = "http://mail.google.com/mail/x/"; $page = file_get_contents($url); preg_match_all('/<input type=\"hidden\" name=\"([^"]+)\".*?value=\"([^"]*)\"[^>]*>/is', $page, $matches, PREG_SET_ORDER); $num = (count($matches)-1); for($i = "0"; $i <= $num; $i++) { $post .= urlencode($matches[$i][1]) . "=" . urlencode($matches[$i][2]) . "&"; } $remove = array("amp%3B" => ""); $continue = strtr(urlencode($matches[1][2]), $remove); $posts = strtr($post, $remove); $user_agent = "NokiaE50-1/3.0 (06.27.1.0) SymbianOS/9.1 Series60/3.0 Profile/MIDP-2.0 Configuration/CLD-1.1"; $email = "cumcum82%40gmail.com"; $pass = "XXXXXXXX"; $action = "https://www.google.com/accounts/ServiceLoginAuth?service=mail"; $referer = "https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=" . $continue . "&bsv=1k96igf4806cy<mpl=ecobx&nui=5&btmpl=mobile"; $cookie = "/var/www/cookies.txt"; $post_fields = $posts . "Email=$email&Passwd=$pass&PersistentCookie=yes&rmShown=1&signIn=Sign%20in"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $action); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_REFERER, $referer); curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded")); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); $result = curl_exec($ch); curl_close($ch); echo $result; ?> Zaman ayıran herkese şimdiden teşekkür. _______________________________________________ Linux-programlama mailing list [email protected] http://liste.linux.org.tr/mailman/listinfo/linux-programlama
