简体   繁体   English

如果限制了Facebook访问,是否可以隐藏Facebook登录按钮

[英]Is there any way to hide facebook login button if facebook access is restricted

I have integrated facebook login button in my site where I got stuck in a scenario where I am trying to hide the facebook login button if I don't have access to facebook. 我在自己的站点中集成了Facebook登录按钮,在这种情况下,如果我无法访问Facebook,则试图隐藏Facebook登录按钮。 Is there any way to check whether I have access to facebook? 有什么方法可以检查我是否可以访问Facebook?

I want to hide this button if I don't have access to facebook.like I in my company there is cyberoam security which don't allow to access facebook & I get warning of cyberoam you don't have access and it distract my site GUI. 如果我没有访问facebook的权限,我想隐藏此按钮。就像我公司中存在的Cyber​​oam安全性不允许访问Facebook一样,同时警告Cyber​​oam您没有访问权限,这会分散我的网站GUI。

Thanks in advance! 提前致谢!

I think you are going about it the wrong way. 我认为您是错误的做法。 In order for you to know that you cannot access a site, you would need to try and access the site. 为了让您知道您无法访问站点,您需要尝试访问该站点。 This would inevitably lead to a delay. 这将不可避免地导致延迟。

You would be better off using ajax to call a routine that checks and if ok displays the login button. 您最好使用ajax调用一个例程来检查,如果确定,则显示登录按钮。 The function below will help: 以下功能将帮助您:

function urlExists($url=NULL)  
{  
    if($url == NULL) return false;  
    $ch = curl_init($url);  
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);  
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);  
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
    $data = curl_exec($ch);  
    $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);  
    curl_close($ch);  
    if($httpcode>=200 && $httpcode<300){  
        return true;  
    } else {  
        return false;  
    }  
}

I claim no credit for the function, it came from here first, I believe: 我不认为该功能值得信赖,它首先来自这里,我相信:

http://www.wrichards.com/blog/2009/05/php-check-if-a-url-exists-with-curl/ http://www.wrichards.com/blog/2009/05/php-check-if-a-url-exists-with-curl/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM