1

I have been looking for this error but I still have not found anything that prevents it from happening, the thing is that it only happens sometimes and also i get another error on my error´s log

There exists a cookie that we wanted to clear that we couldn't clear because headers was already sent. Make sure to do the first API call before outputing anything
PHP Fatal error:  Uncaught OAuthException: An active access token must be used to query information about the current user. thrown in /...fb_sdk/base_facebook.php on line 1106

Here is the code I am using on the config.php and I am using it on top of all the pages inside my app

<?php
    header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');

    require 'fb_sdk/facebook.php';

   $app_id = 'XXXXXXXXXXXX';
   $app_secret = 'XXXXXXXXXXXX';
   $app_namespace = 'minstagram';
   $app_url = 'https://apps.facebook.com/' . $app_namespace . '/';
   $scope = 'email,publish_actions,user_photos,friends_photos';

   // Init the Facebook SDK
   $facebook = new Facebook(array(
     'appId'  => $app_id,
     'secret' => $app_secret,
     'cookie' => true
   ));

   // Get the current user
   $user = $facebook->getUser();

   // If the user has not installed the app, redirect them to the Auth Dialog
   if (!$user) {
     $loginUrl = $facebook->getLoginUrl(array(
       'scope' => $scope,
       'redirect_uri' => $app_url,
     ));

     print('<script> top.location.href=\'' . $loginUrl . '\'</script>');
   }


?>

So here is my question, hope anybody can help me out here, maybe a way to get a new acces_token if the one i currently have is not valid, or anythi.g.

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
  • You've debugged to ensure no output is being sent prior to calls to `header()` or `cookie()`? Does `output_buffering` solve the problem? – Felix Weelix Jun 18 '12 at 06:49
  • @ClancyHood Hello, i am currently learning PHP how can I debug it? the only way I know right now is just the error log, here is my app [link](https://apps.facebook.com/filter_box/) – Jeronimo Cosio Jun 18 '12 at 08:22
  • http://php.net/manual/en/function.headers-sent.php Headers must be sent before any output (such as "echo") - try the following at different stages in the code: `if(headers_sent($file, $line)) die("Output started in $file on $line");` – Felix Weelix Jun 18 '12 at 08:37
  • could anyone solve this problem? I am getting it too. The exact problem posted at http://stackoverflow.com/questions/13910661/fb-api-cookie-header-error – Pratik Poddar Dec 17 '12 at 13:43

0 Answers0