Joseph Mansfield
Joseph Mansfield

Reputation: 110658

Why is my Facebook Connect button taking me to the wrong URL?

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. :)

Upvotes: 0

Views: 694

Answers (1)

serg
serg

Reputation: 111285

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.

Upvotes: 1

Related Questions