tags:

views:

74

answers:

1

Heyas. I have an flash app that I'm working on that can be embedded on other websites (like YouTube videos), but we want to know what website the user is viewing the site on. Is there any way to tell what site the app is embedded on that the user is viewing on?

The original app is written in flash/actionscript and php running on the server, if that helps. Thanks.

+1  A: 

You can simply retrieve the HTTP referrer header via php, store it somewhere and than serve your flash content...

 <?php

 // served from  http://yoursite.net/your_flash.php


 //read the referer header
 $referer_url = (isset($_SERVER['HTTP_REFERER']))?  $_SERVER['HTTP_REFERER'] : ""; 
 //store it somewhere...

 //read the swf file
 $swf=file_get_contents('flash_app.swf');
 //spit the flash content out with the proper header
 header('Content-type: application/x-shockwave-flash');
 echo $swf;
 ?>

Embed code, to be pasted by third party websites in their HTML:

<object width="550" height="400">
 <embed src="http://yoursite.net/your_flash.php" width="550" height="400">
 </embed>
</object>
And
I can't run the HTTP_REFERER if the flash is embedded in someone else's blog. They would just take the embedded code provided to them. I can't run anything on their server.
JustJon
@justJon, the code i've just posted is meant to be executed by the server which distributes the swf file not by the third parties that embed your content..
And
@And just means to create this wrapper file in PHP and stream the swf from it. To browsers, this looks like native flash because of the header. Call it myflash.php and hand it to users for inclusion. Or call it myflash.swf and use mod_rewrite.
Residuum
@And Then when would that code be called? The user has an embed directly to the swf file. Would the embed call the php file which passes thru the swf?
JustJon
@justJon, exactly! In this way the user is visiting your site without even knowing it :)
And
@And Diabolical! I didn't even think of doing that. Thanks.
JustJon
@justJon never heard about web bugs? http://en.wikipedia.org/wiki/Web_bug
And