【发布时间】:2010-11-18 08:00:39
【问题描述】:
嘿嘿。我有一个我正在开发的 Flash 应用程序,它可以嵌入到其他网站(如 YouTube 视频)中,但我们想知道用户正在哪个网站上查看该网站。有什么方法可以知道用户正在查看的应用程序嵌入在哪个网站上?
如果有帮助的话,原始应用程序是用 flash/actionscript 和 php 编写的,在服务器上运行。谢谢。
【问题讨论】:
嘿嘿。我有一个我正在开发的 Flash 应用程序,它可以嵌入到其他网站(如 YouTube 视频)中,但我们想知道用户正在哪个网站上查看该网站。有什么方法可以知道用户正在查看的应用程序嵌入在哪个网站上?
如果有帮助的话,原始应用程序是用 flash/actionscript 和 php 编写的,在服务器上运行。谢谢。
【问题讨论】:
您可以简单地通过 php 检索 HTTP referrer header,将其存储在某处,然后提供您的 Flash 内容...
<?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;
?>
嵌入代码,由第三方网站粘贴到其 HTML 中:
<object width="550" height="400">
<embed src="http://yoursite.net/your_flash.php" width="550" height="400">
</embed>
</object>
【讨论】: