Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] SendHTTPRequestASync, multiple input, (cannot process (interger, string, string, string)

User Offline
Joined: 4th Dec 2018
Posted: 4th Dec 2018 16:16
I have a question, how to you link the input from a user text box to post within a function for a chat bot program? I can hard code the user name but I need to be able to have a user type it in and it be recalled for posting. help please. Here is the section of code that I am having an issue with.

function PostMessage()
post$ = GetEditBoxText(1)
UserName$ = GetEditBoxText(2)
SetEditBoxText(1, "")
http = CreateHTTPConnection ( )
SetHTTPHost( http, "", 0 )

SendHTTPRequestASync( http, "postmessage.php", "&txtUserName="+UserName$, "&txtChatMessage="+post$)
//SendHTTPRequestASync( http, "postmessage.php","&txtChatMessage="+post$ )
while( GetHTTPResponseReady(http) = 0 )
print("01101100 01101111 01100001 01100100 01101001 01101110 01100111 00101110 00101110 00101110..." )

response$ = "error"
if ( GetHTTPResponseReady(http) > 0 ) then response$ = GetHTTPResponse(http)



Produces this error main.agc:90: error: "sendhttprequestasync" does not accept the parameters (Integer, String, String, String)

The author of this post has marked a post as an answer.

Go to answer

User Banned
Posted: 4th Dec 2018 17:37
As far as i understand this command only accepts 3 parameters

iHTTP = createhttpconnection

SendHTTPRequestASync ( iHTTP, szServerFile$, szPostData$)

What info goes in these is beyond me though
User Offline
Joined: 4th Dec 2018
Posted: 6th Dec 2018 14:48
yes this does seem to be the issue, but how can i get around this? I need it to accept the username, as well as the rest.
User Offline
Joined: 4th Dec 2018
Posted: 6th Dec 2018 15:56
//SendHTTPRequestASync( http, "postmessage.php", "[+post$ ]&txtUserName(GetEditBoxText(2)), &txtChatMessage=(GetEditBoxText(1))" )
SendHTTPRequestASync( http, "postmessage.php","txtUserName=Bender, &txtChatMessage="+post$ )

This code for the line works but as you can see on line 2 the user name is hard coded, I need to get it to accept the username variable.
Line 1 is commented out but as you can see I am trying different ways to make it work, like this configuration. now it doesn't break the program however it also wont accept the post and the php behind the scenes ignores the input.

any help I can get to correct this would be greatly appreciated.
AGK Developer
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 7th Dec 2018 00:42
Just a quick assessment, but

test your connection first, so you can handle not even being able to connect to the site.
This approach works for me.

Send all the URL data which isn't the "site" as one string. You will have to assemble this string yourself like:


Are you able to test your postmessage.php from a browser? Whatever it takes to construct the browser URL to work, just assemble the same structure.
I assume php (I'm no expert) requires the usual ? and & chars on the URL ?

One final thing to remember is that you should URL encode any data that has (or could have) special chars (including spaces).

Here's a couple of functions for that:

DBPro Master
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 7th Dec 2018 01:10 Edited at: 7th Dec 2018 01:10
This post has been marked by the post author as the answer.

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
User Offline
Joined: 4th Dec 2018
Posted: 12th Dec 2018 14:53
Ortu, thank you, that was it the extra "+" works perfectly now

Login to post a reply

Server time is: 2019-06-17 13:48:07
Your offset time is: 2019-06-17 13:48:07