Search code examples
facebookfacebook-graph-api

Facebook.com error with getLoginUrl()


I generate a login url using:

$facebook->getLoginUrl(array('canvas' => 1, 'fbconnect' => 0, "display"=>"page", 'next' => APP_URL, 'req_perms' => 'email,publish_stream,offline_access'))

However, when user clicks the link he is redirected to the page with a Facebook logo and a message 'Go to Facebook.com' underneath it. Why is this happening and how to fix it?

A live example: http://apps.facebook.com/soundofcamden/ (just click the authenticate link)


Solution

  • $login_url  = $facebook->getLoginUrl(array('canvas' => 1,'fbconnect' => 0, 'req_perms' => 'email,publish_stream,offline_access', 'next' => APP_URL));
    echo '<div class="notice">You need to <a href="' . $login_url . '" onclick="top.location.href = \'' . $login_url . '\';">authenticate first</a>.</div>';
    

    The solution.