curl-and-php
Cookie - Unix works, Windows doesn't
Date: Sun, 8 Oct 2006 01:25:47 +0200
Hi,
I'm using one of your example scripts to get me started with curl and am
experiencing a problem I can't make head or tails of. I searched this list
and the web, but found nothing.
I updated the ebay-login script and it's working fine on my (commercial)
unix server, but not on my private windows server. The problem seems to lie
in writing information to the cookie, as unix gives me 6 lines, but windows
only 4, using the exact same script. It should be in step 1, as the
line-difference already occured when I commented out step 2. The entire
script also works on windows when I copy the "step 1" contents of the
unix-cookie to the windows-cookie.
I've posted all info that I thought could help below, and would appreciate
it very much if anyone could shine some light on this as I would like to run
the final project (which actually will use some of this) one my windows
server.
Thank you, Marten
___________________________________
I tried to get my servers to match each other as closely as possible and
this is what they look like:
My Windows setup:
Apache/2.0.58 (Win32) PHP/4.4.4
libcurl/7.14.0 OpenSSL/0.9.8a zlib/1.2.3
The Unix setup:
Apache/1.3.26 (Unix) Debian GNU/Linux mod_fastcgi/2.4.2 mod_gzip/1.3.19.1a
PHP/4.3.11
libcurl/7.12.1 OpenSSL/0.9.6c zlib/1.1.4
___________________________________
The cookie:
.ebay.com TRUE / FALSE 0 ebay value
.ebay.com TRUE / FALSE 1223333725 dp1 value
.ebay.com TRUE / FALSE 1191797725 nonsession value
.ebay.com TRUE / FALSE 0 s value
.ebay.com TRUE / FALSE 10 sru value // line appears on
unix only
.ebay.com TRUE / FALSE 1191797725 cid value // line
appears on unix only
(if the cookies-values themselves are needed, let me know and I will post
them, but rather not :p)
___________________________________
The script itself:
$ebay_user_id = "x"; // ebay id
$ebay_user_password = "y"; // ebay password
$cookie_file_path = preg_replace('/\\\\/', '/', getcwd()) ."/".
$ebay_user_id .".cookie.txt";
// 1 - Get the Cookies required to login from the welcome login page
$LOGINURL = "http://signin.ebay.com/ws/eBayISAPI.dll?SignIn";
$vcurl = curl_version();
$agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7)
Gecko/20060909 Firefox/1.5.0.7';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
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);
curl_close($ch);
unset($ch);
// 2 - Post Login Cookies and Login Information to Page
http://signin.ebay.com/ws/eBayISAPI.dll
$LOGINURL = "http://signin.ebay.com/ws/eBayISAPI.dll";
$POSTFIELDS =
'MfcISAPICommand=SignInWelcome&siteid=0&co_partnerId=2&UsingSSL=0&ru=&pp=&pa1=&pa2=&pa3=&i1=-1&pageType=-1&rtmData=&userid='.
$ebay_user_id .'&pass='. $ebay_user_password ;
$reffer = "http://signin.ebay.com/ws/eBayISAPI.dll?SignIn";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
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);
$result = curl_exec($ch);
print $result;
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2006-10-08