0

如何检查用户是来自 Facebook 还是直接来自网站?我使用过这种方法 $_REQUEST['signed_request'],但他们只响应一次。

我非常感谢您的回复

if(isset($_REQUEST)){
            if(isset($_REQUEST['signed_request'])){
                $this->result = "fb_platform";  
            }else{
                $this->result = "web_platform"; 
            }
}
4

1 回答 1

0

在一些 Stack Overflow 问题评论之后,我更改了我的代码

<script>
//if a user is coming from 
//facebook or directly from the site.

function platformAuthentication(){ 

    var platform = "fb_platform";
    if(window.self === window.top) {
        platform = "web_platform";
        $("#platform_key").val(platform);
        $("#platform_form").submit();
    }else{
        platform = "fb_platform";
        $("#platform_key").val(platform);
        $("#platform_form").submit();
    }

}
setTimeout(platformAuthentication,500);
</script>


</head>
<body>
<!--hidden form for user tracking, 
    if a user is coming from fb/direclty 
    from the site
-->
<form id="platform_form" name="platform_form" method="post" target="iframe_platform" action="url">
<input type="hidden"  id="platform_key" name="platform_key" />
</form>
<iframe id="iframe_platform" name="iframe_platform" src="url">
</iframe>
于 2013-07-03T10:36:44.290 回答