C# to Basic4pp problem

Discussion in 'Questions (Windows Mobile)' started by Byak@, Nov 7, 2008.

  1. Byak@

    Byak@ Active Member Licensed User

    i must rewrite this code
    Code:
    {
                
    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:
    Code:
    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(10000As 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!
     

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    \r\n are not special metacharacters in Basic4ppc. You should use the constant CRLF:
    Code:
    str = "first line" & crlf & "second line"
     
  3. Byak@

    Byak@ Active Member Licensed User

    i'm lol!!!!!thanks Erel!!!!big thanks!!!!!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice