i must rewrite this code
to basic4ppc.what i'm do:
but in textbox i have "400 bad request"!
c# code work fine!
please help me!
B4X:
{
string redirect = "";
System.Net.Sockets.TcpClient tc = new System.Net.Sockets.TcpClient();
try
{
tc.Connect(site_host, 80);
}
catch (Exception e)
{
userid = "";
return new Cookie[0];
};
//HEADER
string send =
"POST http://vkontakte.ru/login.php HTTP/1.1\r\n" +
"Host: vkontakte.ru\r\n" +
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1;) Firefox/2.0.0.0\r\n" +
"Connection: Close\r\n" +
"Referer: http://vkontakte.ru/index.php\r\n" +
"Content-Type: application/x-www-form-urlencoded\r\n" +
"Content-Length: ";
// BODY Length & BODY
string s_myText = "email=" + Uri.EscapeDataString(user) + "&pass=" + Uri.EscapeDataString(pass); // +"&success_url=&fail_url&try_to_login=1&submit=.";
send += s_myText.Length.ToString() + "\r\n\r\n" + s_myText;
// Send data
byte[] aa = site_encoding.GetBytes(send);
System.IO.Stream s_s = tc.GetStream();
s_s.Write(aa, 0, aa.Length);
s_s.Flush();
// Receive data
aa = new byte[tc.ReceiveBufferSize];
int count = s_s.Read(aa, 0, (int)aa.Length);
String data = site_encoding.GetString(aa,0,aa.Length);
char[] unused = { (char)data[count] };
data = data.TrimEnd(unused);
s_s.Close();
tc.Close();
to basic4ppc.what i'm do:
B4X:
Sub Button1_Click
client.New1
bit.new1
client.Connect(Client.GetIP2("vkontakte.ru"),80)
stream.New1(client.GetStream,True)
str="POST http://vkontakte.ru/login.php HTTP/1.1\r\n"&"Host: vkontakte.ru\r\n"&"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1;) Firefox/2.0.0.0\r\n"&"Connection: Close\r\nReferer: http://vkontakte.ru/index.php\r\n"&"Content-Type: application/x-www-form-urlencoded\r\n"&"Content-Length: "
str2="email=jendos-91%40mail.ru&pass=123456"
strready=str&StrLength(str2)&"\r\n\r\n"&str2&"\r\n\r\n"
stream.WriteBytes (stream.StringToBytes(strready) )
timer1.Enabled = True
End Sub
Sub Timer1_Tick
If client.DataAvailable = True Then
Dim bufferbits(10000) As byte
count = stream.ReadBytes(bufferbits(),10000)
buffer = bit.BytesToString(bufferbits(),0,count)
textbox2.Text = buffer
timer1.enabled = False
client.Close
End If
End Sub
but in textbox i have "400 bad request"!
c# code work fine!
please help me!