facebookherokufacebook-appsfacebook-authentication

Error in Facebook app redirection, it doesn't redirects canvas page


I have set up a Facebook app using Heroku hosting. When unauthorized user goes to app it shows this

facebook logo and then it redirects to the permissions page . When I click to Go to App button it redirects to http://lovehunt.herokuapp.com not to Facebook canvas page.

However if an authorized user goes to app there is no problem.

below is the code snippet which is written in FBUtils.php

 public static function login($redirect) {
      $app_id = AppInfo::appID();
      $app_secret = AppInfo::appSecret();
      $home = AppInfo::getHome();

      $scope = 'user_likes,user_photos,user_photo_video_tags';
      $authorize_url = "https://www.facebook.com/dialog/oauth?client_id=$app_id" .
      "&redirect_uri=$home&state=" . $state . "&scope=$scope";
      // Now we redirect the user to the login page
      echo("<script> window.top.location='" . $authorize_url . "'</script>");
 }

Solution

  • When unauthorized user goes to app it shows this

    This is typical screen that you try to iframe facebook, as facebook does not let it be iframed itself it gives this page

    So set up with your code that does not try to iframe, probably use something, if it is case with javascript:

    _target="top" 
    

    then it redirects to the permissions page . When I click to Go to App button it redirects to http://lovehunt.herokuapp.com not to facebook canvas page.

    this post applies for above: facebook apps redirect to hosting url in the first usage