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 / Tier 1 http command example?

Author
Message
apocolyp4
14
Years of Service
User Offline
Joined: 10th Jun 2010
Location:
Posted: 5th May 2012 18:05
Has anyone managed to get the http commands to work on tier 1? Ive tried but Im unable to get any reply back.

connectionID = CreateHTTPConnection()
httpAddress = SetHTTPHost(connectionID, url$, 0)
onlineResponse = SendHTTPRequest(connectionID, szServerFile$, parameters$)

Is this the way to use them? The server which Im posting to works fine so thats not at fault.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 5th May 2012 19:52 Edited at: 5th May 2012 19:52
HTTP commands works well for me. Except sometimes when i quit my game the agk player quit instead of returning on the "waiting stream" state (on iOS) when i use them ( with ASync command too).

and yes it's the right way to use them
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 5th May 2012 21:25
I just can not figure out whats supposed to be written in those fields... How did you figure them out...

MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 5th May 2012 22:51 Edited at: 5th May 2012 22:56
Example :

for the URL : http://box.ht/test.php



It's my test server. it will return only "myvar" POST value and "myvar2" POST value
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 6th May 2012 03:28
Thank you MikeMax
Er Merci?

I will try this soon just finishing up a website...

So the variables need to be declared in the php correct?

MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 6th May 2012 04:01
Yes, your script need to know the variables names to handle them. (you can also try to do a var_dump($_POST) to see all the vars you sent but i don't know how AppGameKit will handle the linefeeds in the return)..

for example, this is the PHP script of the page test.php which display the two posted vars :

MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 6th May 2012 04:08 Edited at: 6th May 2012 05:56
Linefeeds are working well :


AGK Code in the client (still with my "box.ht" servername)



The PHP Code in the server :



Result (with a simple print command) :



MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 6th May 2012 05:29
I shall give this a go... thank you so much

apocolyp4
14
Years of Service
User Offline
Joined: 10th Jun 2010
Location:
Posted: 6th May 2012 13:26
Thanks MikeMax your example helped me out. I was missile the ? in my GET.
bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 6th May 2012 16:35
just remember when sending data from the client to the server you need to encode user submitted values. You need to create a similar function to php's urlencode() for use from AGK. Otherwise a crafty user can totally break your code!

Here's a DBP version, it would have to be translated for AGK:

http://forum.thegamecreators.com/?m=forum_view&t=180318&b=6

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 6th May 2012 19:36
I am thinking of playing about with these commands for highscore purposes mainly. I am wondering what would be a good free site to use to play about with? If I can get something working I would probably buy some space. But for tests I am looking for say a geocity type free site (I think that was the last one I used in DB a few years back).

apocolyp4
14
Years of Service
User Offline
Joined: 10th Jun 2010
Location:
Posted: 6th May 2012 22:24
I use the google app engine for hosting my online score board system. https://developers.google.com/appengine/ the free quota is be more than enough for an online line scoreboard system.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 14th May 2012 06:27
Ah, that sounds ideal. Thanks for the info, and sorry for the late reply. I almost forgot about this post.

Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 16th May 2012 17:27
I'm trying to work with these HTTP commands, but I have a slight problem... I have someone 'hosting' my leaderboard (scores etc) as I have no knowledge of PHP nor do I have my own site (yet). All I have is a link which ends with getscores.php. When I access this url it displays all the text of the scores etc, like this:



Is there anyway I can pull this information into a string within AppGameKit without knowing any of the PHP script? Apologies if thats abit of a daft question...
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 16th May 2012 17:50
The 'SendHTTPRequest' command, if set up properly, returns a string.

The string should be the one you listed.

Can you show us the code you are using to connect to the site? (Redact any user name or password.)

Cheers,
Ancient Lady
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 16th May 2012 18:32
Thanks for responding Ancient Lady, here is what I'm trying to do...

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 16th May 2012 18:47
What, if anything, displays when you run the app?

Cheers,
Ancient Lady
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 16th May 2012 18:55
Unfortunately, it doesn't display anything... I'd be happy to send you the link to your email if you wouldn't mind helping me out?
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 16th May 2012 18:57
Just guessing...

Most probably getscores.php can take a username parameter to return that particular username score only.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 16th May 2012 19:04
Yes, please send me the link.

To quote the guys from Mythbusters, "I'm what you call a professional". I've been doing WAMP/LAMP (Windows/Linux Apache/MySQL/PHP) programming for several years.

I've never used the email function on this platform. But I believe that all you have to do is click the 'EMAIL' icon below my posted message.

Cheers,
Ancient Lady
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 16th May 2012 19:22
Thanks Ancient Lady, email sent...

Hello bjadams, that could be a worthy guess... To give you a bit more background, originally I was using a different SDK which used C++, this is what I was doing then (which worked), not sure if that gives you any other clues:



I then used StoreGlobal to parse the data...
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 16th May 2012 20:13 Edited at: 16th May 2012 20:14
Okay, I got the email and finally figured out the problem.

First, in the SetHTTPHost command, you use exactly only the domain name, do not include 'http://' and do not include any subdirectories.

Add the subdirectory (including a leading '/') to the file name in the SendHTTPRequest command:



When you print out the results (the example you sent me), it displays greatly truncated. But the length of the string is correct.

I hope this helps.

Cheers,
Ancient Lady
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 16th May 2012 20:25
I spent a fair few hours looking into an online highscore table yesterday. I have pretty much zero php knowledge, and so am struggling also. I followed Hockeykid's tutorial for DB thinking it would be fairly simple to use AppGameKit in the final procees rather than DB. I forgot how much I hate doing anything web related, whoever thought up these languages must have a fascination with brackets. After spending hours to get a page saying it cannot display properly I gave it neck.
So I might be looking to see if there is anything available that would be somewhat easier for me to get into. I remember Mr_d doing something for DB along those lines, that I was thinking got more and more attractive the longer I flailed around. Other than that back to a simple unsecure file upload and check system I suppose. If I get enough people playing, that hacking the score board is an issue, I can look into it I suppose.

Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 16th May 2012 23:56
Wow, Ancient Lady, thank you so much!
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 17th May 2012 00:11
I am always happy to help.

Happy Programming!

Cheers,
Ancient Lady
Ashambles
12
Years of Service
User Offline
Joined: 9th May 2012
Location: Georgia, USA
Posted: 17th May 2012 02:50
This company has some cloud services like leaderboards and achievements that you can access from your app using just HTTP POST and GET. They have a free tier and the next level is like $20 US a month. Something I'd bookmarked as potentially useful but I haven't used any of it yet.

Twitter: MuseHill
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 17th May 2012 03:13 Edited at: 17th May 2012 03:14
@ Ashambles

Theres a few of us on here who would possibly not mind hosting a page for you... Just start a thread and requeat a hosted leaderboard feature... Im too tired right now so... If I dont make sense... Hopefully six hours later I will be fresh...

EDIT

Typos in bold...

Ashambles
12
Years of Service
User Offline
Joined: 9th May 2012
Location: Georgia, USA
Posted: 17th May 2012 04:03
Thanks, MrValentine. I should have specified that I was mentioning the cloud service in case it was useful to others. In fact, PHP is actually one of the languages I know best and I'd be glad to help if anyone's looking to roll their own

Twitter: MuseHill
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 17th May 2012 20:56
@ Ashambles, ah that site sounds interesting, I will have to investigate. I will be looking into a web site of my own soon so it would be nice to be able to do it on my own site. The only problem with relying on a service for this sort of thing, is that if they go bump you could be left with a bunch of non working games. Well for the highscore anyway. Meaning either you will need to rewrite them for a new system, or leave them not working for online scores. Both of which could interfere with your games ratings etc.
Will have to read through the site first see what it offers, and how easy it is! Thanks for the help!

MarcoBruti
13
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 20th May 2012 00:50
Hi,
this is the PHP code that I use server side. I have a free hosting provider (www.altervista.org) that offers you both PHP and MySQL support for free.
I manage high scores (a very simple table for Kill That Bandit! on Google Play) as a simple JSON file. Pls have a look at the thread in the AppGameKit showcase.
Here is the PHP code I use, very simple, I hope it helps:


and this is the AppGameKit code on the app:

Hope it helps.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 20th May 2012 00:53
Nice one Marco, very simple and useful
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 20th May 2012 01:49 Edited at: 20th May 2012 01:53
Thanks Marco, that looks great! I'll have a play with it. With that template I can probably suss it out. I tried to edit the DB example php code to work with my highscore, but with all the brackets and stuff, wasn't sure if I had missed something obvious without even knowing it, lol. I'm sure there will be a lot of people this will help greatly. Including me!

Login to post a reply

Server time is: 2024-11-23 14:28:22
Your offset time is: 2024-11-23 14:28:22