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:
<?php
$file_name="ktb_hiscore.json";
$temp_file_name="temp_ktb_hiscore.json";
$appo_file_name="appo_ktb_hiscore.json";
if (isset($_GET['level']) and (isset($_GET['score']))) {
$level=$_GET['level'];
$score=$_GET['score'];
$hi_idx=0;
if (file_exists($temp_file_name)) {
unlink($temp_file_name);
}
if (file_exists($appo_file_name)) {
unlink($temp_file_name);
}
$hifile=fopen($file_name,'r');
$hifile_temp=fopen($temp_file_name,'w');
while(!feof($hifile)) {
$line=fgets($hifile);
if (strtok($line,'"')!=false) {
$level_tk=strtok('"');
strtok('"');
$score_tk=strtok('"');
if ($level==$level_tk) {
echo("Updated Level ");
echo($level_tk." Old score=");
echo($score_tk." New score=");
echo($score);
$endcomma="";
if ($level<9) {
$endcomma=",";
}
fputs($hifile_temp,' "'.$level_tk.'": "'.$score.'"'.$endcomma."\n");
} else {
fputs($hifile_temp,$line);
}
}
}
fclose($hifile_temp);
fclose($hifile);
if (rename($file_name,$appo_file_name)) {
if (rename($temp_file_name, $file_name)) {
unlink($appo_file_name);
} else
{
rename($appo_file_name,$file_name);
}
}
} else
{
echo "Error...";
}
?>
and this is the AppGameKit code on the app:
httpConnId=createHTTPConnection()
SetHTTPHost(httpConnId,"agkappmarket.altervista.org",0 )
httpStatus=GetHTTPFIle(httpConnId,"/KillThatBandit/ktb_hiscore.json","ktb_hiscore_old.json")
while (GetHTTPFileComplete(httpConnId)=0)
httpFileProgressStatus=GetHTTPFileProgress(httpConnId)
sync()
endwhile
oldhiscoreFile=OpenToRead("ktb_hiscore_old.json")
if (getFileSize(oldhiscoreFile)=0)
print("No Internet Connection or Server Unavailable")
sync()
sleep(1000)
exitfunction -1
endif
................
SendHTTPRequest(httpConnId, "/KillThatBandit/ktb_set_hi.php?level="+str(lv)+"&score="+strtime(newscore#,3),"")
deleteHTTPConnection(httpConnId)
Hope it helps.