automatyczna rejestracja w curlu

kavil

Użytkownik
Dołączył
Kwiecień 1, 2007
Posty
1
witam napisałem taki prosty skrypcik do erepublik, moje pytanie, bo coś nie działa, jak przechodzę od rejestracji do wpisywania kodu captcha jest wszystko ok, ale jak wpisuję kod nie wykrywa mnie, jakbym pisał oby 2 części:

z góry dziękuję za wykrycie błędu

PHP:
<?php

$naglowki=array('Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
                'Accept-Language: pl,en-us;q=0.7,en;q=0.3',
                'Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7');

$encode = 'Accept-Encoding: gzip,deflate';


function token($content){
     preg_match('/<input type="hidden" id="_token" name="_token" value="(.*?)" \/>/', $content, $w);
     return $w[1];
}
$hand = curl_init();

curl_setopt($hand, CURLOPT_URL, 'http://www.erepublik.com/pl/facebook/referrer/nicker');
curl_setopt($hand, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($hand, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.1)");
curl_setopt($hand, CURLOPT_COOKIESESSION, true);
curl_setopt($hand, CURLOPT_HTTPHEADER, $naglowki);
curl_setopt($hand, CURLOPT_ENCODING, $encode);
curl_setopt($hand, CURLOPT_COOKIEFILE, dirname(__FILE__)."/tmp/cookiefile.txt");
curl_setopt($hand, CURLOPT_COOKIEJAR, dirname(__FILE__)."/tmp/cookiefile.txt");
curl_setopt($hand, CURLPROXY_HTTP, '122.224.33.10:80');
curl_setopt($hand, CURLOPT_AUTOREFERER, true);
$p=curl_exec($hand);


//POBIERANIE TOKENA
curl_setopt($hand, CURLOPT_URL, 'http://www.erepublik.com/pl/referrer/nicker');
$p=curl_exec($hand);
$token = token($p);

if ($_POST['submit'] != 'submit'){
    //WPROWADZENIE DANYCH DO REJESTRACJI
    curl_setopt($hand, CURLOPT_URL, 'http://www.erepublik.com/pl/referrer/nicker');
    curl_setopt($hand, CURLOPT_POST, 1);
    $ok = urlencode('Zostañ obywatelem');
    curl_setopt($hand, CURLOPT_POSTFIELDS, array(
        '_token' => $token, 
        'citizen_name' => 'kavulilo', 
        'citizen_password' => 'adsakura',
        'citizen_password2' => 'adsakura',
        'country_list' => 35,
        'region_list' => 426,
        'region_selected_id' => '',
        'nationality_list' => 192,
        'citizen_email' => '[email protected]',
        'birth_date[]' => Array
        (
            0 => 21,
            1 => 6,
            2 => 1992
        ),
        'gender' => 'M',
        'commit' => $ok,
        'agree' => 1,
        'newsletter' => 1
    ));
    $p=curl_exec($hand);
    echo '<textarea rows="10" cols="150">'.$p.'</textarea><br>';

    //WYSWIETLANIE FORMULARZA
    curl_setopt($hand, CURLOPT_URL, 'http://api.recaptcha.net/noscript?k=6LfEGgIAAAAAABSqQ0rzMd3t-rOU_XrZlC2C9WG2');
    $p=curl_exec($hand);
    preg_match('/<input type="hidden" name="recaptcha_challenge_field" id="recaptcha_challenge_field" value="(.*?)" \/>/',$p,$dana);
    $obraz = 'http://api.recaptcha.net/image?c='.$dana[1];
    echo '<img src="'.$obraz.'" />';
    echo'<form method="POST"><input name="id"><input type="hidden" value="'.$dana[1].'" name="dana"><input type="submit" name="submit" value="submit"></form>';
}else{
    //WYSY£ANIE DANYCH DO RECAPTCHA
    $sub = urlencode('I\'m a Human');
    curl_setopt($hand, CURLOPT_URL, 'http://api.recaptcha.net/noscript?k=6LfEGgIAAAAAABSqQ0rzMd3t-rOU_XrZlC2C9WG2');
    curl_setopt($hand, CURLOPT_POST, 1);
    curl_setopt($hand, CURLOPT_POSTFIELDS, array(
        'recaptcha_challenge_field' => $_POST['dana'], 
        'recaptcha_response_field' => $_POST['id'], 
        'submit' => $sub
    ));
    $p=curl_exec($hand);
    preg_match('/<textarea rows="3" cols="40">(.*?)<\/textarea>/s',$p,$kod);
    //WYSY£ANIE DANYCH CAPTCHA
    curl_setopt($hand, CURLOPT_URL, 'http://www.erepublik.com/pl/register_captcha');
    curl_setopt($hand, CURLOPT_POST, 1);
    curl_setopt($hand, CURLOPT_POSTFIELDS, array(
        '_token' => $token,
        'recaptcha_challenge_field' => $kod[1],
        'recaptcha_response_field' => 'manual_challenge',
        'commit' => $ok
    ));
    $p=curl_exec($hand);
    echo '<textarea rows="10" cols="150">'.$p.'</textarea><br>';
    curl_close($hand);
}
?>
up ??

potrzebuje tego :)
 
Ostatnio edytowane przez moderatora:
Do góry Bottom