0

I am having trouble recently with old users. It is a scenario that is hard to test. Old users are getting errors when I try to force them to use the Enhanced Auth Dialog to add the app to their timeline. I should remark that everything works fine for new users.

Old users authenticate just fine, but if you try a timeline action, they get a #200 error saying publish_actions is needed. Which is expected. So I am trying to solve this is by 1.) checking the join_date of a user to my app. If that date is before I made the enhanced switch then 2.) I check their permissions.

If they don't have publish_actions, like so, I do this:

if(!array_key_exists('publish_actions', $permissions['data'][0]) ) {
 $gotoURL = APP_URL."?page=home";
 $cancelURL = APP_URL."?page=terms&cancel=1";
 $url = $facebook->getLoginUrl(array('canvas' => 1, 'fbconnect' => 0, 
                                     'scope' => 'publish_actions', 
                                     'redirect_uri' => $gotoURL, 
                                     'cancel_url' => $cancelURL));
 echo "<html><body><script>window.parent.location='".$url."';</script></body></html>";
 exit;
}

For some reason, that seems to put them in a redirect loop. I have the latest php sdk, so I don't really know what the issue is, and like I said, it is difficult to test. Any thoughts off hand as to what the problem/solution could be? Is there a better way to do this?

Brett Stubbs
  • 669
  • 1
  • 9
  • 19

1 Answers1

0

They enter a redirect loop because this expression:

if(!array_key_exists('publish_actions', $permissions['data'][0]) )

always evaluates to true. If you figure out how to check the permissions properly, it should work.

That said, in my app I never allow a redirect loop to occur. If the user does not grant permission, she is redirected to a page that explains why we are requesting such permissions (with a button to return to grant permissions). It doesn't really make sense to just redirect her to the same thing again if she already decided that she doesn't want to grant the app permission.

Gil Birman
  • 35,242
  • 14
  • 75
  • 119