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 / SendHTTPFile()

Author
Message
Shokkul
9
Years of Service
User Offline
Joined: 30th Oct 2015
Location:
Posted: 23rd Apr 2016 15:12
Hello Guys,
2 days ago I started a discussion about all the HTTP functions and one friend suggested me a website for learning php and stuff. I bought domain, hosting, I created database tables, I learned php, I can handle query operations with using $_GET and $_REQUEST in php. The only thing left is getting input from AGK2 to my server file. All I need is getting one input like "2", "131" etc. However there is so little information about SendHTTPFile(). My questions are

1) How can I send a file or data from AGK2 to my server file? What are the rules and what are the things that I should be aware of?
2) What is the type of this input?
3) How can I read this file in php

Its my last stage of my game. I've been working 1 month on this game, please help me out guys.
Thanks
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 23rd Apr 2016 21:10 Edited at: 23rd Apr 2016 21:12
Skip that command and just load the PHP file with get values, like a URL in your web browser. On phone, don't remember the command. But the regular one for http.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 23rd Apr 2016 23:20
I'm feeling generous! This is my HTTP send file code from version 2.0 of my Insanity engine, and the PHP file that receives it.

Call Network_Initialise() once at the start of the program
Call Network_Update() every loop. (It'll handle all the network stuff)
Call Network_UploadFileToServer( FileName$, URL$, ServerFile$, PostData$ ) once, to send file FileName$ to URL$ calling ServerFile$ php file and sending PostData$ as post data.

Here's an example:


If you just want to send post data only, you should be able to figure out what code to change in the PHP file.

Hope this helps!

Attachments

Login to view attachments
Shokkul
9
Years of Service
User Offline
Joined: 30th Oct 2015
Location:
Posted: 24th Apr 2016 00:26
Thank you so much guys, I will try your suggestions, I will update if I achive my goal.
Shokkul
9
Years of Service
User Offline
Joined: 30th Oct 2015
Location:
Posted: 24th Apr 2016 00:27
Thank you so much guys, I will try your suggestions, I will update if I achieve my goal.
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 24th Apr 2016 09:43
If you are just doing basic stuff then GetHTTPFile() is all you need in order to talk to a PHP script. You can even do post data.

http://www.appgamekit.com/documentation/Reference/HTTP/GetHTTPFile.htm
Shokkul
9
Years of Service
User Offline
Joined: 30th Oct 2015
Location:
Posted: 25th Apr 2016 20:06 Edited at: 25th Apr 2016 20:07
Thank you for your suggestions guys. The thing is that I solved my problem with using this function( I found this on AppGameKit website)

Function GetFromWeb(URLPath$)
Host$="www.????.com"
Response$=""

if GetInternetState()=1
iHTTP=CreateHTTPConnection()
SetHTTPVerifyCertificate( iHTTP, 0 )
iSecure=0
szUser$=""
szPass$=""
if SetHTTPHost( iHTTP, Host$, iSecure, szUser$, szPass$ )=1
if SendHTTPRequestASync( iHTTP, URLPath$ )=1
do
ret=GetHTTPResponseReady( iHTTP )
if ret=-1 then exit //Cancel
if ret=1 then exit //Ready
print("wait ...")
sync()
loop
if ret=1

Response$=GetHTTPResponse( iHTTP )

endif
endif //Get
CloseHTTPConnection( iHTTP )
endif //Host
DeleteHTTPConnection( iHTTP )
endif //Internet

endfunction


For url path I write something similar to "example.php?name="john"&id=5" and it worked. Plus with this function now I am able to get the output of my php files. So with other php files, I can get my spesific data with query functions.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 27th Apr 2016 10:25
But I gave you plug and play code, AND the php to make it work??

Login to post a reply

Server time is: 2024-11-25 07:42:07
Your offset time is: 2024-11-25 07:42:07