- strpos: documentation ( source)
- get_object_vars: documentation ( source)
- json_encode: documentation ( source)
<?php
// Result to be returned as json
class Result implements \JsonSerializable {
private $error;
private $accessToken;
public function __construct($anErrorName, $anAccessToken)
{
$this->error = $anErrorName;
$this->accessToken = $anAccessToken;
}
public function jsonSerialize()
{
return get_object_vars($this);
}
}
// 1. check if referer is Unity else echo error
$referrer = (string)$_SERVER['HTTP_USER_AGENT'];
if (strpos($referrer, 'Unity') !== false) {
// we're pl
} else {
$result = new Result("true", 0);
echo json_encode($result);
exit();
}
foreach( $_POST as $key=>$value) {
if( is_array( $value ) ) {
foreach( $value as $thing ) {
echo $thing . "\xA";
}
} else {
echo "$key=$value" . "\xA";
}
}
echo'test' . "\xA";;
?>