0

I am trying to load the facebook php sdk in the wordpress template. I've added the code to the header.php file:

    locate_template( 'facebook/facebook.php', true );

$facebook = new Facebook(array(
     'appId'  => appid,
     'secret' => appsecret
));

$signedRequest = $facebook->getSignedRequest();

if ( isset($signedRequest['app_data']) )
{
    echo $signedRequest['app_data'];    
} 

But I get get this error:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent..

How can I load the facebook sdk before any other file is loaded

1

You shouldn't add functionality to themes. Or even worse: To templates. Wrap it up in a plugin and load the plugins bootstrap on plugins_loaded, or - in case of a mu-plugin - on muplugins_loaded.

In every case, you shouldn't throw around with globals. Just add your output to a custom filter or hook and only add this one to your template: (Example) do_action( 'facebook_app_data' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.