i'm building facebook app to be accessed via mobile device and keep getting after the user accepts the app permissions and is returned to the original url:
CSRF state token does not match one provided.
however my redirect_uri is the same url sending the request. I've checked my facebook app settings and the app domain is entered correctly.
here's my code:
<?php
require 'facebook/src/facebook.php';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => 'MY_APP_ID',
'secret' => 'MY_SECRET',
));
// Get User ID
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
$friends = $facebook->api('/me/friends');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
?>
<?php if ($user) { ?>
<?php echo $user_profile['id']; ?><br />
<pre><?php print_r($user_profile); ?></pre><br />
<?php
foreach($friends["data"] as $item){
echo $item["name"]. ' - '. $item["id"]. '<BR>';
}
?>
<?php }else{ ?>
<br />
<a href="https://www.facebook.com/dialog/oauth?client_id=MY_APP_ID&scope=email,publish_stream&display=touch&redirect_uri=<?php echo urlencode('https://www.domain.com/app/mobile.php?'); ?>">App.</a></body>
<?php } ?>