Facebook app reloads himself after permission grant

alper069

New Member
I have a little Facebook app, that posts some preloaded images. I changed the code structure, so i moved all the variables into config.php, so it would be more comfortable. But after that the app doesn't work and i really don't know why... After the permission dialog it realoads himself over and over... Can someone fing the bug?This is the index.php:\[code\]<?phprequire 'facebook.php';require 'config.php';$facebook = new Facebook(array('appId' => $appId,'secret' => $appSecret,'baseUrl' => $baseUrl,'appBaseUrl' => $appBaseUrl,'fileUpload' => 'true','cookie' => 'true'));if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) { $baseUrl = str_replace('http','https',$baseUrl); $fbPageURL = str_replace('http','https',$fbPageURL); $fbPageAppURL = str_replace('http','https',$fbPageAppURL);}else{ // not https} $signed_request = $facebook->getSignedRequest(); $page_id = $signed_request["page"]["id"]; $like_status = $signed_request["page"]["liked"]; if(!$like_status){ header("Location: notfan.php"); exit; }$user = $facebook->getUser();$params = array( scope => 'publish_stream,user_photos', redirect_uri => $fbPageAppURL );$loginUrl = $facebook->getLoginUrl($params);$app_data = http://stackoverflow.com/questions/10557889/$signed_request["app_data"];?> <!doctype html> <html xmlns:fb="http://www.facebook.com/2008/fbml"> <head> <title><?php echo $appName; ?></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <style> a:link {color:#f1effc;} a:visited {color:#f1effc;} a:hover {color:#19378d;} a:active {color:#19378d;} a:link {text-decoration: none} </style> </head> <body> <script type="text/javascript"> function NotInFacebookFrame() { return top === self; } function ReferrerIsFacebookApp() { if(document.referrer) { return document.referrer.indexOf("apps.facebook.com") != -1; } return false; } if (NotInFacebookFrame() || ReferrerIsFacebookApp()) { top.location.replace("<?= $fbPageAppURL ?>"); } </script><?php if($user){ try { $user_profile = $facebook->api('/me'); $scope = 'publish_stream,user_photos'; $scope_params = explode(',',$scope); $permissions = $facebook->api("/me/permissions"); if( array_key_exists('publish_stream', $permissions['data'][0]) && array_key_exists('user_photos', $permissions['data'][0])) { // the main app logic here } else { $user = null; } } catch (FacebookApiException $e) { error_log($e); $user = null; } } if ($user) { // logged in user } else { // not logged in or not authenticated echo '<script type="text/javascript">top.location.hrefhttp://stackoverflow.com/questions/10557889/= "'.$loginUrl .'";</script>'; }?> </body></html>\[/code\]and the config.php:\[code\]<?php$appName = 'the name';$appId = '123456789';$appSecret = '1324v3434v34v';$baseUrl = 'http://www.domain.com/app-name/';$appBaseUrl = 'http://apps.facebook.com/zzzzzzz/';$fbPageURL = 'http://www.facebook.com/xxxxxxx';$fbPageAppURL = $fbPageURL.'?sk=app_'.$appId;?>\[/code\]Thank you very much!!
 
Back
Top