cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

I do no keep logged in while opening a new page

From: Uber Jaegeraar <jaegeraar_at_gmail.com>
Date: Tue, 6 Nov 2007 00:58:05 +0100

I'm working on a script to login to betbrain and automatically load a
page I need. I use the following code which works correctly. If I echo
the second curl_exec and take a look at the betbrain source code it
shows my username. After I executed the code below and logged in I
would like to open a few pages. I tried many things and it is no
problem to get the page but I am not logged in anymore!

$betbrain_user_id = "xxx";
$betbrain_user_password = "xxx";
$randnum = rand(1,9999999);
$cookie_file_path = "/tmp/cookiejar-".$randnum."";
$LOGINURL = "http://www.betbrain.com/";
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4)
Gecko/20030624 Netscape/7.1 (ax)";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt ($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_HEADER,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_exec ($ch);
if (curl_errno($ch)) {
 print curl_error($ch);
} else {
         curl_close($ch);
         unset($ch);
}

$LOGINURL = "http://www.betbrain.com/userLogin.do";
$POSTFIELDS = 'username='. $betbrain_user_id .'&password='.
$betbrain_user_password;
$reffer = "http://www.betbrain.com/";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt ($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_HEADER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$POSTFIELDS);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_exec ($ch);
if (curl_errno($ch)) {
         print curl_error($ch);
} else {
         curl_close($ch);
         unset($ch);
}

As an example I would like to visit this page:
http://betbrain.com/oddsDetail/Football-England-Premier_League_2007_2008/eventId/61127334/betTypeId/26/scopeId/0/site/0
but remain logged in so I retrieve additional bookmaker odds. I've
used the code below and many variations on it but nothing worked for
me.

$ch = curl_init();
curl_setopt($ch,
CURLOPT_URL,'http://betbrain.com/oddsDetail/Manchester_City-Sunderland/eventId/107156442/betTypeId/43/scopeId/2/site/0');
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt ($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_HEADER,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$result = curl_exec ($ch);
if (curl_errno($ch)) {
         print curl_error($ch);
} else {
         curl_close($ch);
         unset($ch);
}
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-11-06