为什么我的Facebook Connect按钮带我错误的网址? [英] Why is my Facebook Connect button taking me to the wrong URL?

查看:111
本文介绍了为什么我的Facebook Connect按钮带我错误的网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果我在PHP SDK中调用名为getLoginUrl()的方法,它将返回正确的登录URL。此URL包含多个参数,其中一个是我的API密钥,它是正确的。这是我的连接按钮应该带我的URL。



但是,当我实际点击我的网站上的连接按钮时,会弹出一个弹出窗口,并说无效API密钥指定。有一点检查,我看到这个弹出窗口中的URL表示api_key = undefined。实际上,该URL与登录URL应该是完全不同的。



任何想法为什么会发生这种情况?
只有冲突我可以想象是codeigniter或jQuery。



很难更具体。我猜想这将需要很好的了解Facebook SDK的答案。



非常感谢。 :)

解决方案

如果需要,PHP应该只处理登录回调,应该通过javascript完成登录。



FB api初始化:

 < div id =fb-root>< / DIV> 
< script src =http://connect.facebook.net/en_US/all.js>< / script>
< script>
FB.init({
appId:appId,
status:true,
cookie:true,
xfbml:true
});
< / script>

然后可以在某些按钮上触发fb登录对话框:

  FB.login(function(response){
// callback
},{perms:'publish_stream'});

还要确保您的fb应用程序在连接选项卡下有正确的设置 - 连接网址和基本域应该设置。如果他们链接到错误的域名,您将无法登录。


I'm trying to link my website with Facebook.

If I call the method in the PHP SDK called getLoginUrl(), it returns the correct login URL. This URL contains a number of parameters, one of which is my API key and it is correct. This is the URL that my Connect button is supposed to take me to.

However, when I actually click the Connect button on my site, a popup opens and says "Invalid API key specified". With a bit of inspection, I see that the URL in this popup says "api_key=undefined". In fact, the URL is completely different to what the login URL should be.

Any idea why this is happening? Only conflicts I can imagine are codeigniter or jQuery.

It's hard to be more specific. I'm guessing this will require good knowledge of the Facebook SDK to answer.

Thanks a lot. :)

解决方案

PHP should handle only login callback if necessary, login should be done through javascript.

FB api initialization:

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
    FB.init({
        appId  : appId,
        status : true,
        cookie : true,
        xfbml  : true
    });
</script>

Then you can trigger fb login dialog on some button:

FB.login(function(response) {
    //callback
}, {perms:'publish_stream'});

Also make sure you have correct settings in your fb app under "Connect" tab - "Connect URL" and "Base Domain" should be set. If they link to a wrong domain you won't be able to login.

这篇关于为什么我的Facebook Connect按钮带我错误的网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆