I am writing a Facebook application that is designed to be displayed through a page tab on my own business page. I need to interact with the viewer user, so I need advanced permissions.
I followed the suggested procedure, but now hit the wall. My application is in an iFrame, and the extended rights request uses redirection. I can get a page on which you need to confirm authorization, but when you click "Allow", Facebook redirects the page where my application is placed, and not back to my tab on the Facebook page. Once the correct rights have been resolved, the rest of the application works fine, so I know this is just a redirect problem, but I feel like I tried everything and many people did not seem to have the same problem. I wish someone could point me in the right direction.
Thanks!
Here is my code:
$app_id = "myappid"; $canvas_page = "http://wheremyappishosted/"; $signed_request = $_REQUEST["signed_request"]; list($encoded_sig, $payload) = explode('.', $signed_request, 2); $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true); $user_id = $data["user_id"]; $access_token = $data['oauth_token']; if (empty($data["user_id"])) { $auth_url = "https://graph.facebook.com/oauth/authorize?client_id=".$app_id."&redirect_uri=".urlencode($canvas_page)."&scope=user_photos,friends_photos,publish_stream,user_likes"; die("<script> top.location.href='" . $auth_url . "'</script>"); } $f = json_decode(file_get_contents("https://graph.facebook.com/".$user_id."?access_token=".$access_token."&fields=name,albums,likes"), true);
source share