Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

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' );

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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