diff options
Diffstat (limited to 'app.php')
-rw-r--r-- | app.php | 80 |
1 files changed, 80 insertions, 0 deletions
@@ -9,6 +9,86 @@ include "includes/datas.php"; //echo "working...";
+if ($_GET['act'] == "test") {
+
+//header('Content-Type: text/xml');
+header("Content-Type: text/plain");
+
+if ($_POST['XMLRequest']) {
+ $string = $_POST['XMLRequest'];
+} else {
+ $string = '<!-- request -->
+<BrainMazeAPI version="0.1">
+ <APIRequest>
+ <SubmitScore>
+ <MapID>5</MapID>
+ <Username>FiftyToo</Username>
+ <Score>50</Score>
+ </SubmitScore>
+ </APIRequest>
+</BrainMazeAPI>';
+}
+
+$xml = simplexml_load_string($string);
+
+//echo $xml->APIRequest->SubmitScore->MapID;
+//print_r ($xml);
+
+
+
+
+$score = $xml->APIRequest[0]->SubmitScore[0]->Score;
+$username = $xml->APIRequest[0]->SubmitScore[0]->Username;
+
+//echo $xml->getName() . "<br />";
+// foreach($xml->children() as $child) {
+// echo $child->getName() . ": " . $child . "<br />";
+// }
+
+
+//$score = 50;
+$previousScore = 49;
+$rank = 1;
+
+//Begin XML Response
+$w = new XMLWriter();
+$w->openMemory();
+$w->startDocument('1.0','UTF-8');
+$w->startElement("BrainMazeAPI");
+ $w->writeAttribute("version", "0.1");
+ $w->startElement("APIResponse");
+ $w->startElement("SubmitScore");
+ $w->writeAttribute("result", "SUCCESS");
+
+ $w->startElement("rank");
+ $w->text($rank);
+ $w->endElement();
+
+ $w->startElement("update");
+ $w->text('true');
+ $w->endElement();
+
+ $w->startElement("UsernameUsed");
+ $w->text($username);
+ $w->endElement();
+
+ $w->startElement("SubmittedScore");
+ $w->text($score);
+ $w->endElement();
+
+ $w->startElement("PreviousHighScore");
+ $w->text($previousScore);
+ $w->endElement();
+
+ $w->endElement();
+ $w->endElement();
+$w->endElement();
+echo $w->outputMemory(true);
+
+}
+
+
+
if ($_GET['act'] == "submit") {
header('Content-Type: text/xml');
echo '<!-- response -->
|