0

I have a Facebook Canvas app that works with ids ?id= and I wanted to make the urls look a bit nicer so I added this to my htaccess file.

RewriteEngine On

RewriteRule ^u(.*?)\.php$ index.php?id=$1

This is the Login url for facebook

$facebook->getLoginUrl(array('canvas' => 1, 'scope' => 'permissions', 'redirect_uri' => 'http://domain.com/u'.$id.'.php'));

So it goes to u123456789.php after authenticating. Now my problem is that $facebook->getUser(); always returns 0 even if the user has authenticated and allowed the app because of that redirect.

If I redirect to index.php after authenticating it works fine.

I think this is caused by the session or something. Is there any solution to make it work?

Thanks in advance

Matthias Dunnowa
  • 119
  • 1
  • 1
  • 12
  • Well you didn't give any context as to how $facebook->getUser() is supposed to get its value. Is it the id parameter? – Mike Brant Jul 27 '12 at 16:59
  • The id is something else, the code is like this $facebook = new Facebook(array( 'appId' => $appid, 'secret' => $secret, 'cookie' => true )); // Get User ID $user = $facebook->getUser(); if ($user) { try { $user_profile = $facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); $user = null; } } – Matthias Dunnowa Jul 27 '12 at 17:02
  • I guess I am still failing to see the connection between your rewrite rule and your Facebook class if the id parameter is not related to the user. – Mike Brant Jul 27 '12 at 17:06
  • It is not about the id but about the user variable always being 0 when redirecting to u123456.php while it works with index.php – Matthias Dunnowa Jul 27 '12 at 17:11
  • So how does the code in u123456789.php differ from that in index.php? – Mike Brant Jul 27 '12 at 17:14

0 Answers0