• 31-12-2013, 22:41:58
    #1
    arkadaşlar bir sayfaya login olmaya çalışıyorum curl ile ama hata veriyor. login formuna geri dönüyor. giriş yapacağım formun kodları bunlar.
    <table cellpadding="0" cellspacing="0" align="center"><tr><td valign="top">
    <form action="https://www.site.com/m/l/" method="post" style="display:inline" onsubmit="return verenvio(2);" autocomplete="off" id="loginform">
    <input type="hidden" name="lge" value="65ABC63868BD65BF1707F899C9773406F2D9CD83B41890ABA143A1843AB2A67C35590DFBEFCDEACC4AB6D08F693A90D1FFEFF7D233C7B456F82B3910BCC996D285FC0F9C8CCB9AE256C6AC1D955E11B5C881EFBDB83E17BFC13B6883608A94282AEFAB335A24FE563C7AACA894069F123152D42227C940E384AA899D1621E664682CF4E9E14FEB49E924D958AE90A32E3C8AA7C74398CB199D2D4DAE04D4A72939B16D151AF084FBADCA08C4D29E58F5D27FD99736A69B21A7CCF87DD4C3CD5951087D440C8C35AE0D88A55CCEF264A592C17C1F5A4E084C82EC7FFB01001BFA0F767F28E63CCCD849C04EB5900CC695888E931501620232C2AAA05819D4307560DE2FB175CEA460B4B21EBD3E97BDD3741B622147DA751BB5DBBC88161AAAF3E88FCDCEF2D4739C5248F69537BE962356BDE8CFA76FB1C83C65933FBB54EC8AD07507FAF10474265E622C61CA76B96E19C6DF8622D8C8C3A3CE45EE97C7CB0C" />
    <table cellpadding="0" cellspacing="0" align="center" id="Kf0"><tr>
    <td valign="top">
    <table cellpadding="1" cellspacing="0"><tr>
    <!--USENAME-->
    <td class="f_r" align="right" nowrap onclick="tT('Kf1')" style="cursor:pointer;font-size:14px;">Username:&nbsp;</td><td>
    <input type="text" name="A80E5602D9320C1AA5B0EDDF33702CF6" id="Kf1" class="campotexto" style="width:155px;font-size:12px;" maxlength="14" onfocus="campo(this.id,14,/^[0-9a-zA-z]+$/)" onKeyUp="campo(this.id,14,/^[0-9a-zA-z]+$/)" onClick="campo(this.id,14,/^[0-9a-zA-z]+$/)" onblur="this.style.backgroundColor=''" placeholder="Username"/></td><td></td></tr>
    <!--PASSWOD-->
    <tr><td class="f_r" align="right" nowrap onclick="tT('Kf2')" style="cursor:pointer;font-size:14px;">Password:&nbsp;</td>
    <td><input type="password" name="ADADE9AF0A5ABC5090077BFC9FD8EB73" id="Kf2" class="campotexto" style="width:155px;font-size:12px;" maxlength="100" onfocus="campo(this.id,100,'')" onKeyUp="campo(this.id,100,'')" onClick="campo(this.id,100,'')" onblur="this.style.backgroundColor=''" placeholder="Password"/></td></tr>
    <!--PASSWOD 2-->
    <tr><td class="f_r" align="right" nowrap onclick="tT('Kf4')" style="cursor:pointer;font-size:14px;">Secondary Password:&nbsp;</td>
    <td><input type="password" name="A60E045DC757E6ED1FE9A2C40D7DBF32" id="Kf4" class="campotexto" style="width:155px;font-size:12px;" maxlength="100" onfocus="campo(this.id,100,'')" onKeyUp="campo(this.id,100,'')" onClick="campo(this.id,100,'')" onblur="this.style.backgroundColor=''" placeholder="Secondary Password"/><br></td></tr>
    
    <input type="hidden" name="AF7750A538012B627DB6AE0CBCDFAD4D" id="Kf3" value="" />
    <input type="hidden" name="login" value="1" />
    gönder kısmı
    <a class="button medium green" onselectstart="return false;" onclick="verenvio(1)" id="botao_login"><span>send</span></a>
    onclick verenvio(1) diye javascript eklemiş. java dan anlamam ama kodları bunlar olması lazım
    <script>
    function verenvio(o){var a1=d00('Kf1').value.length;
    					var a2=d00('Kf2').value.length;
    					var a3=5;var a4=d00('Kf4').value.length;
    					var ax='Kf1';
    					if(a1<4||a1>14||a2<4||a2>100||a3!=5||(a4>0&&(a4<4||a4>100)))
    						{if(a1<4||a1>14) ax='Kf1';
    						else if(a2<4||a2>100) ax='Kf2';
    						else if((a4>0&&(a4<4||a4>100))) ax='Kf4';
    						else if(a3!=5) ax='Kf3';d00(ax).style.backgroundColor='#fdc';
    							d00(ax).focus();return false;}
    							else{d00('btl1').style.display='none';
    									d00('btl2').style.display='';
    									for(a=1;a<5;a++){d00('Kf'+a).style.backgroundColor='';
    													d00('Kf'+a).style.color='#aaa';
    													d00('Kf'+a).readOnly=true;}
    					if(o==1) jQuery('#loginform').submit(); else return true;}}
    					jQuery(document).keypress(function(e){if(e.keyCode==13||e.charCode==13){verenvio(1);return false;}});
    					campos=['Kf1','Kf2','Kf4','Kf3'],shift=false,clock=false;</script>
    form action da yazan url login formu ile aynı. benim kodlarım
    <?php
    $url="http://www.site.com";
    $baglan="https://www.site.com/m/l/";
    
    $cookie_file_path = fopen("cookie.txt","r+"); 
    $useragent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)";    
            
      
        
    
    $ch = curl_init($url); // oturum baslat
    //POST  adresi
    curl_setopt($ch, CURLOPT_URL,$baglan);
    //curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
    curl_setopt($ch , CURLOPT_REFERER , $url);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
    
    $site= curl_exec ($ch);
    
    
    $user1= explode('</td><td><input type="text" name="',$site);
    $user= explode('"',$user1[1]);
    
    $pass1= explode('Password:&nbsp;</td><td><input type="password" name="',$site);
    $pass= explode('"',$pass1[1]);
    
    $pass_2= explode('Secondary Password:&nbsp;</td><td><input type="password" name="',$site);
    $pass2= explode('"',$pass_2[1]);
    
    $hidden1= explode('</tr><input type="hidden" name="',$site);
    $hidden= explode('"',$hidden1[1]);
    
    $submit1= explode('value="" /><input type="hidden" name="',$site);
    $submit= explode('"',$submit1[1]);
    
    $lge1= explode('name="lge" value="',$site);
    $lge= explode('"',$lge1[1]);
    
    $login=array(   $user[0]   =>"kullanıcı",
    				$pass[0]   =>"şifre",
    				$pass2[0]  => "",
    				$hidden[0] => "",
    				"lge"      =>$lge[0],
    				"login"    =>"1"  
    				);
    				
    foreach ( $login as $key => $value) 
    {
        $post_items[] = $key.'='.$value;
    }
    $post_login = implode ('&', $post_items);
    echo $post_login."<br>";
    
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_login);
    $site1 = curl_exec ($ch);
    
    curl_close ($ch);
    if($site1!=true){echo "basarisiz.";}else{
    echo $site1;}
    ?>
  • 01-01-2014, 22:21:30
    #2
    günceldir arkadaşlar yardım bekliyorum
  • 02-01-2014, 17:23:44
    #3
    hala aramaktayım
  • 02-01-2014, 17:41:48
    #4
    sunucunda curl aktifmi?
  • 02-01-2014, 17:48:58
    #5
    allow adlı üyeden alıntı: mesajı görüntüle
    sunucunda curl aktifmi?
    evet localhostta deniyorum. login sayfasını geri veriyor. ayrıca tarayıcınız doğru veri göndermiyor diye hata mesajı veriyor site
  • 03-01-2014, 12:56:08
    #6
    Üyeliği durduruldu
    <? 
    $kullanici_kodu = $_POST['usercode'];
    $kullanici_adi = $_POST['username'];
    $sifre = $_POST['pass'];
    $sayfa="http://abone.iha.com.tr/yeniabone/Login.aspx";
    $ch = curl_init();
    if (!$ch) { die ("Curl oturumu baslatamadim.."); }
    curl_setopt($ch, CURLOPT_URL,$sayfa); 
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch,CURLOPT_POSTFIELDS,"__EVENTTARGET=&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=/wEPDwUKMTkxMTA2ODM3Ng9kFgICAw9kFggCAw8PFgIeBFRleHQFHklQIE51bWFyYW7EsXogOiA4OC4yNDAuMTU4LjEzOGRkAgcPEGRkFgECAWQCCQ8WAh4HVmlzaWJsZWgWAmYPZBYEAgMPDxYCHwAFCW9sYXl0YWtpcGRkAhEPDxYEHwAFRkJveWxlIGJpciBJUCBhZHJlc2kgc2lzdGVtZGUga2F5aXRsaSBkZWdpbC5JUCBpbGUgZ2lyacWfIHlhcMSxbGFtYWTEsS4fAWdkZAILDxYCHwFnFgJmD2QWAgIZDw8WBB8ABUZCb3lsZSBiaXIgSVAgYWRyZXNpIHNpc3RlbWRlIGtheWl0bGkgZGVnaWwuSVAgaWxlIGdpcmnFnyB5YXDEsWxhbWFkxLEuHwFnZGRkvZSP7c0HpeowODMzsHcCgSMYF80=&__SCROLLPOSITIONX=0&__SCROLLPOSITIONY=0&__EVENTVALIDATION=/wEWCgLV48CrAgLT3MG6AwLM3MG6AwLDs+vUDwKSsJLeDALjqqICAo7f/eoNApyy+qQKAoWayroIAsqZvbMHQhWUVN7dh1zeclj2RuxYxtxbyiw=&rblLoginType=1&textboxKullaniciKodu=$kullanici_kodu&KullaniciAdi=$kullanici_adi&textboxKullaniciSifre=$sifre&buttonOKManualLogin=Giriş Yap");
    curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
    $user_agent = "Mozilla/5.0 (X11; U; Linux x86_64; en; rv:1.9.0.19) Gecko/20080528 Epiphany/2.22"; 
    curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
    $data = curl_exec($ch); 
    curl_close($ch);  
     
    ?>
     
    <?
    function CurlFunc($url)
    {if (!extension_loaded(curl))
    {
    die("Extension yuklu degil socket deneyebilirsin");
    }
    $ch = curl_init();
    if (!$ch) { die ("Curl oturumu baslatamadim.."); }
    curl_setopt($ch, CURLOPT_URL,$url); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    //curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
    $user_agent = "Mozilla/5.0 (X11; U; Linux x86_64; en; rv:1.9.0.19) Gecko/20080528 Epiphany/2.22"; 
    curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
    $data = curl_exec($ch); 
    curl_close($ch);  
    return $data;
    }
    $site=CurlFunc("http://abone.iha.com.tr/yeniabone/RSS2.aspx?Kategori=0&Sehir=1"); // Alinacak Siteyi Belirliyoruz.
      
    preg_match_all('#<title>(.*?)</title>#si',$site,$bilgi,PREG_SET_ORDER); 
    // Preg_match_all Alinacak heryeri belirliyruz benzerlerini tabi
    $say=count($bilgi);           // Burda ise preg_match_all icinden gelen kactane veri varsa onlari sayi degerini veriyor.
    for($i=1; $i<10; $i++){           // Burda ise her preg_match_all deki verilerin araliklarini alir ve ekrana yazdiri yada sql'a yazdirirsin
    $haberbaslik=$bilgi[$i][1];
     
    print $haberbaslik;
     
    }
    ?>

    örnek olarak alabilirsiniz.

    sade ve basit.
  • 04-01-2014, 17:59:05
    #7
    Sample adlı üyeden alıntı: mesajı görüntüle
    <? 
    $kullanici_kodu = $_POST['usercode'];
    $kullanici_adi = $_POST['username'];
    $sifre = $_POST['pass'];
    $sayfa="http://abone.iha.com.tr/yeniabone/Login.aspx";
    $ch = curl_init();
    if (!$ch) { die ("Curl oturumu baslatamadim.."); }
    curl_setopt($ch, CURLOPT_URL,$sayfa); 
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch,CURLOPT_POSTFIELDS,"__EVENTTARGET=&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=/wEPDwUKMTkxMTA2ODM3Ng9kFgICAw9kFggCAw8PFgIeBFRleHQFHklQIE51bWFyYW7EsXogOiA4OC4yNDAuMTU4LjEzOGRkAgcPEGRkFgECAWQCCQ8WAh4HVmlzaWJsZWgWAmYPZBYEAgMPDxYCHwAFCW9sYXl0YWtpcGRkAhEPDxYEHwAFRkJveWxlIGJpciBJUCBhZHJlc2kgc2lzdGVtZGUga2F5aXRsaSBkZWdpbC5JUCBpbGUgZ2lyacWfIHlhcMSxbGFtYWTEsS4fAWdkZAILDxYCHwFnFgJmD2QWAgIZDw8WBB8ABUZCb3lsZSBiaXIgSVAgYWRyZXNpIHNpc3RlbWRlIGtheWl0bGkgZGVnaWwuSVAgaWxlIGdpcmnFnyB5YXDEsWxhbWFkxLEuHwFnZGRkvZSP7c0HpeowODMzsHcCgSMYF80=&__SCROLLPOSITIONX=0&__SCROLLPOSITIONY=0&__EVENTVALIDATION=/wEWCgLV48CrAgLT3MG6AwLM3MG6AwLDs+vUDwKSsJLeDALjqqICAo7f/eoNApyy+qQKAoWayroIAsqZvbMHQhWUVN7dh1zeclj2RuxYxtxbyiw=&rblLoginType=1&textboxKullaniciKodu=$kullanici_kodu&KullaniciAdi=$kullanici_adi&textboxKullaniciSifre=$sifre&buttonOKManualLogin=Giriş Yap");
    curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
    $user_agent = "Mozilla/5.0 (X11; U; Linux x86_64; en; rv:1.9.0.19) Gecko/20080528 Epiphany/2.22"; 
    curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
    $data = curl_exec($ch); 
    curl_close($ch);  
     
    ?>
     
    <?
    function CurlFunc($url)
    {if (!extension_loaded(curl))
    {
    die("Extension yuklu degil socket deneyebilirsin");
    }
    $ch = curl_init();
    if (!$ch) { die ("Curl oturumu baslatamadim.."); }
    curl_setopt($ch, CURLOPT_URL,$url); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    //curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
    $user_agent = "Mozilla/5.0 (X11; U; Linux x86_64; en; rv:1.9.0.19) Gecko/20080528 Epiphany/2.22"; 
    curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
    $data = curl_exec($ch); 
    curl_close($ch);  
    return $data;
    }
    $site=CurlFunc("http://abone.iha.com.tr/yeniabone/RSS2.aspx?Kategori=0&Sehir=1"); // Alinacak Siteyi Belirliyoruz.
      
    preg_match_all('#<title>(.*?)</title>#si',$site,$bilgi,PREG_SET_ORDER); 
    // Preg_match_all Alinacak heryeri belirliyruz benzerlerini tabi
    $say=count($bilgi);           // Burda ise preg_match_all icinden gelen kactane veri varsa onlari sayi degerini veriyor.
    for($i=1; $i<10; $i++){           // Burda ise her preg_match_all deki verilerin araliklarini alir ve ekrana yazdiri yada sql'a yazdirirsin
    $haberbaslik=$bilgi[$i][1];
     
    print $haberbaslik;
     
    }
    ?>

    örnek olarak alabilirsiniz.

    sade ve basit.
    verdiğiniz örneğe göre inceledim doğru yapıyorum gibi geldi. hatayı bulamadım. çerezleri almıyor sanırım cookie.txt boş kalıyor. ekranda siteden gelen hata
    "tarayıcınız doğru bilgi göndermiyor" diyor
  • 06-01-2014, 20:10:48
    #8
    ben hala çözemedim bunu soğudum valla php den kafam basmadı bi türlü
  • 13-01-2014, 01:27:38
    #9
    $cookie_file_path = fopen("cookie.txt","r+");
    kısmını;

    $cookie_file_path = "cookie.txt";
    olarak değiştirip deneyin cookie kayıt için.