HttpWebRequest,ebay,Cookie!

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
{
}
}
}
 
J

Joerg Jooss

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,
 
G

Guest

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
 
J

Joerg Jooss

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top