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 / HTTP Commands? Android / IOS Compatibility

Author
Message
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 30th Mar 2014 14:46
My App is using AppGameKit HTTP commands to communicate with MySQL database
through PHP scripts.

I have submitted my app onto Google & Amazon Play and all is well and working. Tested on multiple Android/Kindle devices and no problems connecting in any instance.

Now I am just at the testing stage in XCODE before I release for IOS and the same app as above will not work. The app does not crash, however it will not connect with my HTTP Code.

Is there any known problems here on the forum of fixing this to work on both platforms? Compatibility fixes? Suggestions?
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 30th Mar 2014 17:45
I suggest to use the OBJ C, as for me it never worked.
Are you using Tier 1 or 2 on Android?

Long life to Steve!
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 30th Mar 2014 18:13 Edited at: 30th Mar 2014 18:14
I'm using TIER 1 AGK.

I think I'm actually connecting. The problem seems to be in my PHP code.

I fixed the HTTP connect error by setting Security = 1 and entering my username, pswd in the command.
(found a post here about that issue) Now have this one:

Here's my XCODE ERROR:

2014-03-30 11:06:49.066 Soaring BlueJay[481:60b] Connection to https://sbjleaderboard:mypassword#@avilesapps.com/leaderboard/checkuser.php closed unexpectedly
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 30th Mar 2014 19:17
If my connection works on IOS and the error is my php closed unexpectedly: how is that possible?

The php script works fine on Androids but fails on IOS.

Can the syntax be wrong from one platform to the other?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 30th Mar 2014 19:31 Edited at: 30th Mar 2014 19:32
what happens if you copy the php url in browser at your device?
https://avilesapps.com/
give me a endless loop
http://avilesapps.com/
work normal

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 30th Mar 2014 19:59
Yes, in fact for me on IOS work and on Android don't.
I use Tier 2 on each platform, and never worked on both.
This is why i'm using an external code.

Long life to Steve!
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 30th Mar 2014 20:21
It works fine.
There are some small bugs with it though and they've gone unfixed for some time.
https://code.google.com/p/agk/issues/detail?id=612&can=4
You can't have special characters in the password when connecting to a secure directory in iOS. Not sure why.

https://code.google.com/p/agk/issues/detail?id=634&can=4
You cannot have SSL on with a password protected directory when using AGK's SendHTTPFile command.

I'm not sure what special characters were causing the problem for me on iOS. I simply went with alphanumerics in the password instead. If that doesn't work try shutting off the HTTPS setting in SetHTTPHost(). The SSL connection works fine for me on both platforms, but maybe you have a new issue with AppGameKit and your SSL.

Make sure to check the issue logs for stuff like this. I've got a lot of reports in there that have solutions, but I believe are still considered bugs. I've no idea if TGC will ever address these. SO it is helpful if others use that forum and also post their problems. Or post a message on an already created issue to let AppGameKit know that others are awaiting a fix!

aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 30th Mar 2014 21:40
NAPHIER to the rescue! I have the character: # in my password

ex. password = "password#"

I'm going to try to change this and see if it works. However, GoDaddy requires a special character in the password.

Also, I wrote my PHP scripts with notepad originally. They work fine with Android but when I was done I used: http://phpcodecleaner.com/ to make some neater code then pasted the generated cleaned code into PSPad editor and saved them as their corresponding *.php files then re-uploaded them to my server and had many errors. I guess my question is what php editor should i use? Seems like PHP is very unforgiving of spaces and blank lines!
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 30th Mar 2014 21:45
On the contrary, PHP is VERY forgiving of spaces and blank lines.
I use NotePad ++ it's perfect for me and even has plugins for FTP.

I'd try some different characters with GoDaddy. I'm surprised they force character restrictions on protected directories. If you can't get around this then you should contact Paul and see if he can get a patch in. He should also look at fixing sending files over SSL to a script in a protected directory. These are ugly security problems.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 30th Mar 2014 22:35
Quote: "I guess my question is what php editor should i use?"

I would recommend either TextPad (not free) or CrimsonEditor (free, I think).

Both are excellent for doing pure text editing without adding any special characters.

Also, if you have MS Visual Studio (the 2010 Express C++ version is free and works well with AGK), that also does good, plain text editing.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
The Zoq2
15
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 30th Mar 2014 23:01
I would recommend Sublime Text 2 for any text editing needs It has great syntax highlighting for a ton of languages and plugins that can do almost anything. It has a license fee but the "trial" version works forever

Say ONE stupid thing and it ends up as a forum signature forever. - Neuro Fuzzy
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 30th Mar 2014 23:22
I have to use a special character in my password! Just when I think my app is finished I find myself screwed again! Everything works fine on Android/Amazon devices.

This ones gonna take a while!
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 30th Mar 2014 23:44
Just called GoDaddy. I do not have SSL Security and My Directories are unprotected. I LOST!!
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 30th Mar 2014 23:48 Edited at: 30th Mar 2014 23:50
A publicly usable SSL certificate is something you have to explicitly add to a domain and it requires a dedicated IP address (both that and the SSL certificate have fees associated with them).

And, you can set up user name/password protection on a directory accessable via the web without requiring an SSL certificate. And you have to manually set it up. It is not something automatically generated. This applies to something that the public could use.

There are, obviously, user name and password associated with your GoDaddy account and with your access to your domain (I use GoDaddy as well). These are not what you would want to use to restrict access to parts of your domain.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 31st Mar 2014 00:03
Ancient Lady: With that said. Everything is working fine on Android side of my app with HTTP without SSL and/or a protected directory. Is the SSL Certificate and a protected directory required to get this working for IOS using the same AppGameKit HTTP code the works fine for Android in my app?

When I setup MySQL database I setup the database/username as the same and also a separate password for my database. Did it through PHPmyadmin. Is that what you mean? (I really don't care at this point to protect my server as I'm really just a hobbyist trying to learn for future! $$$)
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 31st Mar 2014 00:21
No, neither SSL nor protected directory should be necessary.

I am doing a high score setup using my domain (www.triassicgames.com) and I don't use SSL or directory protection for that. And it works fine in iOS, Android, Windows and Mac (all the same code). I am working in Tier 2.

The user name and password used to access your database are NOT the same as the ones you might use for directory protection.

If you don't have an SSL certificate that you installed, then using https (with or without user name and password), it won't work. This would cause an error on the web server and that would trickle down to trying to execute the php script.

Can you show the code you are using to do the connection and page request? Maybe the Android version is being more forgiving about something that the iOS version doesn't like.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 31st Mar 2014 00:55
Just use an unprotected directory. Your database password is only used in your PHP script.
So just use
SetHTTPHost( connectionID, "www.yourdomain.com", 0)

http://www.jaguarpc.com/
Has protected directories and MySQL for $5 per month and you can set the password on the directory to whatever you like.
I really don't like GoDaddy's webhosting, but their domain registration is very nice.

aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 31st Mar 2014 01:05 Edited at: 31st Mar 2014 02:28
HERE YOU GO: (I have to clean up the code when complete!)

This function is called when a user clicks the Leaderboard button for the first time. (Or if his/hers local Username.txt doesn't exist). It checks the database to make sure username doesn't exist and if not it will insert the new user into database.

I know the code is very sloppy but I didn't get a chance to clean it up. It does work on Android and when I learn a little more on PHP I'm gonna just use 1 script file to achieve this task.



checkuser.php




createuser.php




config.php


Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 31st Mar 2014 02:44
Quote: "I really don't like GoDaddy's webhosting, but their domain registration is very nice."

Agreed. I keep one domain hosted there for mail server variety. The rest of my sites are on my JaguarPC VPS. But GoDaddy is great for customer support. You can easily get a real human being fairly quickly on the phone and they do help.

The following should work on both Android and iOS:


Since you don't actually have an SSL certificate, setting the iSecure parameter to 1 will not work.

And the user name and password you are passing in the call would only work if you had the directory stored in the sDirectory AppGameKit variable password protected. Trying to actually apply it where it doesn't exist might also be part of the problem.

The rest of the code looks okay.

And drop the "header('Access-Control-Allow-Origin: *');" line in your PHP file, it is not be needed and may be adding to the connection issue.

And just as a note, you should not post the actual user name and password with the database here. You basically gave away all anyone needs to try to hack your database.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 31st Mar 2014 13:14 Edited at: 31st Mar 2014 13:18
Thank you again Ancient Lady.
Password I posted was just an example.

Going to get a good book on PHP. For the little experience I have
with it (last couple days) I truly feel like I can do many things
with it in the future for web based apps.

Will work on this and cleaning my code all day tomorrow.
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 31st Mar 2014 20:55 Edited at: 31st Mar 2014 21:29
OMG! -> Cleaned up all my code and still had same error!

Here was the problem! (Just had to post it in case anyone else encounters this.):

In this stage of my HTTP Request:



And the next stage when perc# >= 100:



*****Timing was off and the File Progress was not really 100%
before trying to open checkuser.dat so that file never existed for that moment causing the ERROR that's been driving me crazy.

My temp fix is to make the app SLEEP like this:

My new code:


Should I use:
if ( perc# >= 100.0 )
If GetFileExists( "checkuser.dat" ) = 0
rem This will keep decrementing perc# until checkuser.dat really exists.
perc# = perc# - 1
else
NewUser_stage = 4
endif
endif


Is this sufficient? Or will it cause errors? The delay is probably only a millisecond. Don't know why!
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 31st Mar 2014 21:33
You should be using GetHTTPResponseReady to test if the upload is done. With GetHTTPFileProgress you will get a 100% on failure. It's not designed to tell you success, but is instead designed to only tell you progress of the request.

http://www.appgamekit.com/documentation/Reference/HTTP/SendHTTPFile.htm

Shows a very clear example of sending a file to a server.

Don't use sleep() for anything but debugging. It will tell the operating system that the app is not responding. Use this instead:



aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 31st Mar 2014 22:27
Naphier: Thank You Again

Why do these commands exist in a language if they are dangerous
to your program? lol

You know GOTO, SLEEP !

Just makes me wonder how many more commands like that
I've been using that are bad.
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 31st Mar 2014 22:31
Sleep has it's place, but really only in debugging.
Goto... well it has no place anywhere, but that's opinion more than anything
Sleep is really bad.
Message is not great either, but it's OK if you understand it's behavior (Windows it will stop the AppGameKit program - most bits - Android the program will continue to run).
It's hard to tell because there's not a ton of usage notes in the online help files and nobody seems to have time to update them

Login to post a reply

Server time is: 2024-11-25 03:26:07
Your offset time is: 2024-11-25 03:26:07