Announcement

Collapse
No announcement yet.

C# to PB?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • C# to PB?

    I could use a little help translating the following C# code. Its
    purpose is to open a connection to a web server, send a token in
    the header and receive a response. The C# code works, the PB code
    does not. This code appears to be opening the connection, butI am not
    getting a response.The URL in the code is changed for security
    purposes.

    [CODE}
    WebRequest myRequest = WebRequest.Create("www.testurl.com/mypage);

    myRequest.Headers.Add("TEST-TOKEN", this.txbToken.Text.Trim() ) ;

    ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy();

    using ( WebResponse response = myRequest.GetResponse() )
    {
    Object retUrl = response.Headers["TEST-URL"];
    Object retSta = response.Headers["TEST-STATUS"];
    }
    [/CODE]

    My best guess is below. I don't know what to do with the certificate
    stuff, if anything.

    Code:
        TCP OPEN "https" AT "www.testurl.com" AS #1 TIMEOUT 15000
        IF ERR THEN
            sTemp$ = "Error on open:" + STR$(ERR)
        ELSE
            TCP SEND #1, "GET /mypage"
            TCP SEND #1, "TEST-TOKEN=MYVALUE"
            DO
                TCP RECV #1, 4096, Buffer$
                s$ = s$ + Buffer$
            LOOP WHILE ISTRUE LEN(Buffer$) AND ISFALSE ERR
            TCP CLOSE #1
            sTemp$ = s$
        END IF
    Thanks in advance for the help!

    ------------------
    John Gibson
    Drake Software
    John Gibson
    Drake Software
Working...
X