HttpWebRequest,ebay,Cookie!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello!

This is my problem: I would like acces to my ebay account with post data.
I have a problem with cookie.
The registration in the ebay website work well after there is an error" you
navigator doesn't accept cookie"
I have try to cookiecontainer without success.
If you try the ebayname and ebaypassword aren't good.

If you have any idea!

Best regards,

Wavemill



HttpWebRequest request =
(HttpWebRequest)WebRequest.Create("http://www.ebay.fr");

request.ContentType = "application/x-www-form-urlencoded";
request.Method = "GET";
CookieContainer myCookie = new CookieContainer();
request.CookieContainer = myCookie;

HttpWebResponse res = (HttpWebResponse)request.GetResponse();

StreamReader resStream = new
StreamReader(res.GetResponseStream());

string responseStr = resStream.ReadToEnd();
resStream.Close();
res.Close();

try
{
string EbayUsername = "login";
string EbayPassword = "password";
string PostData =
string.Format("MfcISAPICommand=SignInWelcome&userid={0}&pass={1}",
EbayUsername, EbayPassword);

HttpWebRequest myReq =
(HttpWebRequest)WebRequest.Create("http://signin.ebay.fr/aw-cgi/eBayISAPI.dll");
myReq.Method = "POST";
myReq.CookieContainer = myCookie;

myReq.ContentType = "application/x-www-form-urlencoded";
myReq.ContentLength = PostData.Length;
myReq.KeepAlive = true;

Stream OutStream = myReq.GetRequestStream();
try
{
ASCIIEncoding encoder = new ASCIIEncoding();
byte[] baPostData = encoder.GetBytes(PostData);
OutStream.Write(baPostData, 0, baPostData.Length);
}
finally
{
OutStream.Close();
}

using (WebResponse response = myReq.GetResponse())
{
try
{
// Get the stream associated with the response.
using (Stream receiveStream =
response.GetResponseStream())
{
using (StreamWriter sw = new
StreamWriter(@"C:\Documents and Settings\Berdoues\Desktop\zz.htm"))
{
// Pipes the stream to a higher level stream
reader with the required encoding format.
using (StreamReader readStream = new
StreamReader(receiveStream, Encoding.UTF8))
{
this.webBrowser.DocumentText =
readStream.ReadToEnd();
/*foreach (Cookie cook in res.Cookies)
{
this.textBox1.Text += cook.Value +
"/n/n";
}*/
}
}
}
}
finally
{
response.Close();
}
}
}
finally
{
}
}
}
 
Thus wrote wavemill,
Hello!

This is my problem: I would like acces to my ebay account with post
data.
I have a problem with cookie.
The registration in the ebay website work well after there is an
error" you
navigator doesn't accept cookie"
I have try to cookiecontainer without success.
If you try the ebayname and ebaypassword aren't good.
If you have any idea!

eBay probably checks the browser type (i.e. User-Agent HTTP header). Set
HttpWebRequest.UserAgent to a well known UA string. You can find a nice list
at http://en.wikipedia.org/wiki/User_agent.

Cheers,
 
Hello!

Thank you for your ansxer!

I have try with:
myReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
..NET CLR 1.1.4322)";

But without succes!

If you have an other idea!
I have search in the web without succes!

Best regards,

Wavemill
 
Thus wrote wavemill,
Hello!

Thank you for your ansxer!

I have try with:
myReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
SV1;
.NET CLR 1.1.4322)";
But without succes!

If you have an other idea!
I have search in the web without succes!
Best regards,

I suggest you use Fiddler to capture the HTTP traffic while you access the
site using a web browser, and program a sequence of HttpWebRequests according
to that capture.

Cheers,
 
Back
Top