curl-and-php
Getting and passing a cookie...
Date: Sun, 16 Feb 2003 17:26:11 -0800
I need this fixed within 48 hours. We have a PHP script to upload auctions to eBay. They changed their login page and we can't get logged in now. We are able to get the cookie, but don't know how to write it to a file on our server. Also, how to pass it back. If this script works, you can then go to www.ebay.com and on the top left it will say 'log out' - which means you are now logged in. It shouldn't be hard, but we are just stumped. USERNAME and PASS have been inserted where you need to put a working username and password. Registration is free, so it is easiest if you sign up for an account if you don't already have one.
Thanks in advance,
Here is the code:
=================================
<?
echo "Getting page...<br>";
# Prepare curl to post to login page at http://cgi3.ebay.com/aw-cgi/eBayISAPI.dll
$useragent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER,1);
curl_setopt($ch, CURLOPT_USERAGENT,$useragent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/mycookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/mycookies.txt");
curl_setopt($ch, CURLOPT_URL,"http://cgi3.ebay.com/aw-cgi/eBayISAPI.dll");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "MfcISAPICommand=SignInWelcome&siteid=0&co_partnerId=2&UsingSSL=0&ru=&pp=&pa1=&pa2=&pa3=&i1=-1&pageType=-1&userid=USERID&pass=PASSWORD&keepMeSignInOption=1");
ob_start(); // prevent any output
$page = curl_exec($ch); // execute the curl command
ob_end_clean(); // stop preventing output
echo "<PRE>".htmlentities($page);
curl_close ($ch);
unset($ch);
echo "Setting cookies...<br>";
#setcookies();
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/mycookies.txt");
curl_setopt($ch, CURLOPT_URL,"http://www.ebay.com/");
$buf2 = curl_exec($ch);
curl_close($ch);
?>
=======================
Aaron Morris
contact_at_paperstuff.com
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-02-17