Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


HTTP Post


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-25-2008, 08:28 PM
Newbie
 
Join Date: Jan 2008
Posts: 6
Default HTTP Post

I'm trying to post variables to a PHP script that repeats back requested information, but I'm having trouble getting it to actually display. Here's what I have:

Code:
Sub loginButton_Click
	Request.New1("http://tixscan.net/api/login.php")
	Request.Method = "POST"
	Request.Timeout = 30000
	Request.ContentType = "application/x-www-form-urlencoded"
	bin.New1(Request.GetStream,true) 'Use a BinaryFile object to write the data to the Request stream.
	bin.WriteString("api=1")
	Response.New1
	Response.Value = Request.GetResponse
	result = Response.GetString
	Response.Close
	Msgbox(result)
End Sub
Everything compiles right and runs, but when the message box pops up, it's just blank. It should display a zero (0) in it.

Any ideas?
Reply With Quote
  #2 (permalink)  
Old 01-26-2008, 11:58 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,134
Default

Your code seems right.
Are you sure that it should return 0?
Reply With Quote
  #3 (permalink)  
Old 01-28-2008, 07:43 PM
Newbie
 
Join Date: Jan 2008
Posts: 6
Default

Yes. I have another API that returns "NO" if the value sent is not found, and when I use the URL for that one Basic4ppc always displays "NO" even though I know the API I am sending is correct. (These APIs work in my other apps, but not in Basic4ppc). I think there is a problem with how it is sending the "api=1" string (1 is the API key for my test account).

Thanks
Reply With Quote
  #4 (permalink)  
Old 01-28-2008, 11:14 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 154
Default

I had a similar problem about six months ago... try the same code as GET instead of POST and see what it returns.

Gary
Reply With Quote
  #5 (permalink)  
Old 01-30-2008, 10:52 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,134
Default

BinaryFile.WriteString adds the string length as the message prefix and therefore should not be used here.
You should use BinaryFile.WriteBytes:

Bit is a Bitwise object.
Code:
Sub Globals
 Dim Buffer(0) as Byte
End Sub

Sub loginButton_Click
    Bit.New1
    Request.New1("http://tixscan.net/api/login.php")
    Request.Method = "POST"
    Request.Timeout = 30000
    Request.ContentType = "application/x-www-form-urlencoded"
    bin.New1(Request.GetStream,true) 'Use a BinaryFile object to write the data to the Request stream.
    s = "api=1"
    buffer() = bit.StringToBytes(s,0,StrLength(s))
    bin.WriteBytes(buffer())
    Response.New1
    Response.Value = Request.GetResponse
    result = Response.GetString
    Response.Close
    Msgbox(result)
End Sub
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
HTTP POST error message miataman Questions & Help Needed 10 07-11-2008 11:28 AM
HTTP POST error Elrick Bug Reports 3 05-24-2008 03:06 PM
HTTP Post fails if Umlauts sent and UTF-8 is used TWELVE Questions & Help Needed 11 04-29-2008 11:13 AM
HTTP POST on Device - error message TWELVE Questions & Help Needed 6 04-26-2008 10:35 AM
HTTP Post ohkovar Questions & Help Needed 3 07-07-2007 05:36 PM


All times are GMT. The time now is 05:29 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0