I have a script in second life building a json string which is base64 encoded and sent to a PHP script.
Login(string action)
{
string json_string = "{\"Action\": \""+action+"\", \"Name\": \""+simName+"\", \"OwnersKey\": \""+ (string)llGetOwner() +"\", \"ObjectID\": \""+ (string)objectID +"\", \"ParcelName\": \""+ parcelName +"\"}";
string data = "Data=" + llStringToBase64(json_string);
toWebPage(data);
}
toWebPage(string params)
{
params += "&FromSL=true";
string tst = "";
if(DEBUG)
{
tst = "/tst";
}
myRequest = llHTTPRequest(URL + PRODUCTNAME + tst + "/"+controller+".php",
[HTTP_METHOD, "POST",
HTTP_MIMETYPE, "application/x-www-form-urlencoded"],
params);
}
There are two times I call the Login script.
Login("RegisterTower");
creating the json string
{"Action": "RegisterTower", "Name": "Korzun", "OwnersKey": "8d13fa0f-b54d-43c9-8426-f7cb28f93cfd", "ObjectID": "be4885a4-a596-6a65-925e-470f149e9b63", "ParcelName": "~Lost Lands~"}
and
Login("CheckInTower");
creating the json string
{"Action": "CheckInTower", "Name": "Korzun", "OwnersKey": "8d13fa0f-b54d-43c9-8426-f7cb28f93cfd", "ObjectID": "be4885a4-a596-6a65-925e-470f149e9b63", "ParcelName": "~Lost Lands~"}
These json strings a base64 encoded and sent to the php script. The first script they hit is Main.php
<?php
include_once "Controller.php";
$params = $_GET;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$params = $_POST;
}
Controller::Process($params);
?>
Controller is as such
<?php
include_once 'Common.php';
include_once 'Entities.php';
include_once 'Database.php';
<?php
class Controller
{
public static function Process($data)
{
echo base64_decode($data["Data"]);
}
}
?>
When I check the results I get
{"Action": "RegisterTower", "Name": "Korzun", "OwnersKey": "8d13fa0f-b54d-43c9-8426-f7cb28f93cfd", "ObjectID": "be4885a4-a596-6a65-925e-470f149e9b63", "ParcelName": "~Lost Lands~"}
{"Action": "CheckInTower", "Name": "Korzun", "OwnersKey": "8d13fa0f-b54d-43c9-8426-f7cb28f93cfd", "ObjectID": "be4885a4-a596-6a65-925e-470f149e9b63", "ParcelName": "~Lost LandsHŸ
Why does the second json string decode with
"~Lost LandsHŸ
when the first did it
"~Lost Lands~"}
UPDATE: As suggested by Decent Dabble The contents of $data["Data"] each time is
eyJBY3Rpb24iOiAiUmVnaXN0ZXJUb3dlciIsICJOYW1lIjogIktvcnp1biIsICJPd25lcnNLZXkiOiAiOGQxM2ZhMGYtYjU0ZC00M2M5LTg0MjYtZjdjYjI4ZjkzY2ZkIiwgIk9iamVjdElEIjogImJlNDg4NWE0LWE1OTYtNmE2NS05MjVlLTQ3MGYxNDllOWI2MyIsICJQYXJjZWxOYW1lIjogIn5Mb3N0IExhbmRzfiJ9
and
eyJBY3Rpb24iOiAiQ2hlY2tJblRvd2VyIiwgIk5hbWUiOiAiS29yenVuIiwgIk93bmVyc0tleSI6ICI4ZDEzZmEwZi1iNTRkLTQzYzktODQyNi1mN2NiMjhmOTNjZmQiLCAiT2JqZWN0SUQiOiAiYmU0ODg1YTQtYTU5Ni02YTY1LTkyNWUtNDcwZjE0OWU5YjYzIiwgIlBhcmNlbE5hbWUiOiAifkxvc3QgTGFuZHN In0=
I am assuming now i have posted this, the problem is the space at the end of the second one. The original data I send is
eyJBY3Rpb24iOiAiQ2hlY2tJblRvd2VyIiwgIk5hbWUiOiAiS29yenVuIiwgIk93bmVyc0tleSI6ICI4ZDEzZmEwZi1iNTRkLTQzYzktODQyNi1mN2NiMjhmOTNjZmQiLCAiT2JqZWN0SUQiOiAiYmU0ODg1YTQtYTU5Ni02YTY1LTkyNWUtNDcwZjE0OWU5YjYzIiwgIlBhcmNlbE5hbWUiOiAifkxvc3QgTGFuZHN+In0=
So now how do I solve that???