Advaliant php curl login, need some help.

Status
Not open for further replies.

eliquid

Serpwoo.com
May 10, 2007
7,206
205
63
A/B Testing
Man, I have been coding for years and I have done this in the past with Advaliant, but I lost my script and had to re-create it.

However, I cant seem to get past the login when doing cUrl. I keep getting errors and cant login with it. I know how to scrape the data I need inside ( my stats ).

Anyone have some code that has already accomplished this? Im banging my head on the wall as to way I am not getting past the login. I have checked everything about 6 times now.

The error I get is incorrect "_viewfile" variable, but it IS correct when I check it.

Many thanks ahead of time.
 


I'm not registered there so I can't login, but it seems there's no _viewfile variable. There are only 5 vars: __VIEWSTATE, TxtLoginNamenew, TxtPasswdnew and login button x and y coordinates.
 
What are the errors you are getting?

Pretty much, there's no way you can get a static script, it'll have to be dynamic (a double cURL handle).. so you are gonna have to cURL the login page, grab the dynamic __VIEWSTATE, then have it post with the grabbed VIEWSTATE (as if it were a user logging in).
 
  • Like
Reactions: Pr0xyhub
I'm really hoping that their new portal also has some sort of API. Good luck with logging in, sounds like a pain.
 
Just checked it out, and wrote this:

Code:
<?

// Settings, what the hell
$globalUser = "imalittleaffiliateboy";
$globalPass = "12345";

// Extracts from $text in between $openingMarker and $closingMarker
function returnSubstrings($text, $openingMarker, $closingMarker) {
    $openingMarkerLength = strlen($openingMarker);
    $closingMarkerLength = strlen($closingMarker);
    $result = array();
    $position = 0;
    while (($position = strpos($text, $openingMarker, $position)) !== false) {
        $position += $openingMarkerLength;
        if (($closingMarkerPosition = strpos($text, $closingMarker, $position)) !== false) {
            $result[] = substr($text, $position, $closingMarkerPosition - $position);
            $position = $closingMarkerPosition + $closingMarkerLength;
        }
    }
return $result;
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://portal.advaliant.com/Login.aspx");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
$grabber = curl_exec($ch);
curl_close($ch);

$grabviewstate = returnSubstrings($grabber, "VIEWSTATE\" value=\"", "\"");

$postvars = "btnLogin.x=53&btnLogin.y=12&TxtLoginNamenew=$globalUser&TxtPasswdnew=$globalPass&__VIEWSTATE=" . urlencode($grabviewstate[0]) . "";

$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_COOKIEJAR, "/tmp/cookiejar-{" . rand(0000,9999) . "}");
curl_setopt($ch2, CURLOPT_COOKIEFILE, "/tmp/cookiejar-{" . rand(0000,9999) . "}");
curl_setopt($ch2, CURLOPT_URL, "http://portal.advaliant.com/Login.aspx");
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch2, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
curl_setopt($ch2, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded"));
curl_setopt($ch2, CURLOPT_POST, 1);
curl_setopt($ch2, CURLOPT_POSTFIELDS,$postvars);

$grabber2 = curl_exec($ch2);
curl_close($ch2);

echo $grabber2;


?>

GOOD LUCK! You can figure out the rest, I'm sure ;)
 
  • Like
Reactions: eliquid
yeah they should have an api to pull stats and offers. At least I know hitpath and directtrack (copeac, ads4dough, cpaempire..) do.

If you ever want to pull your stats it's very simple using soapclient.php and the wsdl docs.

NuSOAP: DirectTrackWebServices


Some networks you have to ask them to turn it on for you. And some have it enabled network wide. I might whip up a little script in the next day or so if I have time to show you how it works if you don't get it easily.
 
just rep + you too... i was for some reason not getting in myself, but your script works hands down

Yup, sure.. what smaxor said would probably work as well (unless you are trying to do something else which I think is the case).

The main thing that I think you probably forgot/didn't catch was the urlencode() that is required for the __VIEWSTATE.. it was the same for MySpace.. *cough cough* ;)
 
Status
Not open for further replies.