• 23-12-2013, 22:39:24
    #1
    Reveloper
    arkadaşlar curl ile login oluyorum ancak içindeki bir yazıyı çekemiyorum?

    <?php
    error_reporting(E_ALL); ini_set("display_errors", 1);
    # First call gets hidden form field authenticity_token
    # and session cookie
    $ch = curl_init();
    $sTarget = "https://www.nic.tr/";
    curl_setopt($ch, CURLOPT_URL, $sTarget);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookie.txt");
    curl_setopt($ch, CURLOPT_REFERER, "https://www.nic.tr/");
    $html = curl_exec($ch);
    
    # parse authenticity_token out of html response
    preg_match('/<input type="hidden" name="PHPSESSID" value="([a-zA-Z0-9]*)">/', $html, $match);
    $authenticity_token = $match[1];
    
    $username = "****-metu";
    $password = "*****";
    
    # set post data
    $sPost = "newHandle=$username&password=$password&authenticity_token=$authenticity_token&mainLoginSubmit=GİRİŞ";
    
    # second call is a post and performs login
    $sTarget = "https://www.nic.tr/index.php";
    curl_setopt($ch, CURLOPT_URL, $sTarget);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $sPost);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: application/x-www-form-urlencoded"));
    
    
    
    # display server response
    $yeni=curl_exec($ch);
    
    preg_match('@<title>(.*?)</title>@si',$yeni,$bak);
    echo $bak[1];
    
    curl_close($ch);
    
    
    ?>
    preg_match('@<title>(.*?)</title>@si',$yeni,$bak);
    echo $bak[1];
  • 23-12-2013, 23:14:53
    #2
    Hata nedir? Ne almak istiyorsunuz ama sonuçta ne alıyorsunuz? Başarılı şekilde POST ettiğine emin misiniz? $yeni değişkeninin içeriği nedir kontrol ettiniz mi?
  • 23-12-2013, 23:47:26
    #3
    error_log'daki hatayı yazar mısın? Tümdengelimden gidelim.
  • 24-12-2013, 00:25:08
    #4
    Kimlik doğrulama veya yönetimden onay bekliyor.
    bknz: https://github.com/rmccue/Requests, https://github.com/rmccue/Requests/b...es/session.php
  • 24-12-2013, 01:54:18
    #5
    Reveloper
    psot işlemim başarılı ama error da almıyorum sonuçta almıyorum :S
  • 24-12-2013, 06:45:08
    #6
    Curl_exec' ten sonra tekrar post işlemi yaparken cookie yi göster birde cookie dizinini kontrol et doğruysa yazmışmı onu kontrol et kolay gelsin.
  • 24-12-2013, 08:17:31
    #7
    Üyeliği durduruldu
    hocam şuan mobilden giriyorum link veremiyorum benim profilden konularıma bak iha login diye bir konu olacak orda benim kodlar sağlam işini görür. Ben bağlanmıyor diyordum sorun sunucu ip kaynaklıymiş işini fazlasıile görür