Reputation: 461
I'm building a game tracking system to see where my games are being played and how many times, as the games are hosted on many different websites.
When the game starts, it sends a GET request to a PHP script on my server.
I'm trying to find out the URLs where my games are being played.
I tried a lot of things but seemed to only be able to get the address at which my PHP script was being hosted which isn't exactly useful.
I tried this:
$calling_url = mysql_real_escape_string($_SERVER['HTTP_REFERER']);
But it just seems to be blank every time from different browsers.
So, any ideas on how to find the location where my game's are being played, based on a GET request?
Upvotes: 0
Views: 4715
Reputation: 46602
If the game sends a GET request using the servers resources eg with a <mx:HTTPService
then perhaps you can use gethostbyaddr() function on your server to find out the hostname:
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
But if the request is from the user playing the game im not sure.
Upvotes: 0
Reputation: 3411
You would need to build a querystring. You can do this by sending something like "http://www.domain.com/welcome.php?referalname=site"
Display later by doing this:
You came from <?php echo $_GET["referalname"]; ?>.
Upvotes: 1
Reputation: 2651
Most browsers will send HTTP_REFERER. However, chances are if your users are behind firewall, proxies, they can strip off headers before request reaches you. Finally since you do have your own code embedded on various websites, why don't you simply grab referrer site url and send it to your server like this:
<script type="text/javascript" src="http://myserver.com/game.js?ref=$ref"></script>
where $ref is the actual referrer url. Isn't that easy for you compared to not so reliable http referrer header.
Upvotes: 0