cURL / Mailing Lists / curl-library / Single Mail

curl-library

Curl and eBay-Login

From: Karsten Stein <kasi_at_arcor.de>
Date: Tue, 9 Aug 2005 09:35:02 +0200

Hi,
 
I’ve writen the eBay-Login-Script in C++ (original: http://curl.haxx.se/libcurl/php/examples/?ex=ebay_login.php ). But if I run this program, I’m getting an error from eBay – your browser reject Cockies. Maybe someone can help me. Here’s the code:
 
// 1-Get First Login Page http://signin.ebay.com/aw-cgi/eBayISAPI.dll?SignIn
// This page will set some cookies and we will use them for Posting in Form data.
  char cookie_file_path[] = "f:\\test.txt"; // Please set your Cookie File path
 
  char LOGINURL[] = "http://signin.ebay.com/aw-cgi/eBayISAPI.dll?SignIn&UsingSSL=0&pUserId=XXXXXX&pass=XXXXXXX";
  char agent[] = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";

  CURL *curl_handle;
  curl_handle = curl_easy_init();
  curl_easy_setopt(curl_handle, CURLOPT_URL, LOGINURL);
  curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, agent);
  curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
  curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE, cookie_file_path);
  curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, cookie_file_path);
  curl_easy_perform(curl_handle);
  curl_easy_cleanup(curl_handle);
 
// 2- Post Login Data to Page http://signin.ebay.com/aw-cgi/eBayISAPI.dll
 
  char LOGINURL2[] = "http://signin.ebay.com/aw-cgi/eBayISAPI.dll";
  char POSTFIELDS[] = "MfcISAPICommand=SignInWelcome&siteid=0&co_partnerId=2&UsingSSL=0&ru=&pp=&pa1=&pa2=&pa3=&i1=-1&pageType=-1&userid=XXXXXXX&pass=XXXXXXXXX&submit=Sign In";
  char reffer[] = "http://signin.ebay.com/aw-cgi/eBayISAPI.dll?SignIn";
 
  curl_handle = curl_easy_init();
  curl_easy_setopt(curl_handle, CURLOPT_URL, LOGINURL2);
  curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, agent);
  curl_easy_setopt(curl_handle, CURLOPT_POST, 1);
  curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, POSTFIELDS);
  curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
  curl_easy_setopt(curl_handle, CURLOPT_REFERER, reffer);
  curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE, cookie_file_path);
  curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, cookie_file_path);
  curl_easy_perform(curl_handle);
  curl_easy_cleanup(curl_handle);
 
 
Curls writes the cookiefile in „f:\\test.txt“:
 
# Netscape HTTP Cookie File
# http://www.netscape.com/newsref/std/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.
 
.ebay.com TRUE / FALSE 0 ebay %5Ecv%3D15555%5E
.ebay.com TRUE / FALSE 1186271978 dp1 bu1p/QEBfX0BAX19AQA**44d3df6a^
.ebay.com TRUE / FALSE 1154735978 nonsession BAQAAAQVQcELtAAaAAPIAAULzDnAxAMsAAkLysvIxMADKACBMWK1qODNlMWZjMzcxMDUwYTBiNDYxNjQwZTQwZmZmZDYyZTCiSqvqqdlKfLTebrZVuxBGmO+9tA**
 

 
I can also post the HTTP-Header if this is important. It would be a great help If someone can help me ☺
 
Best regards,
Karsten Stein
 
 
Received on 2005-08-09