Error requesting Facebook PHP Api?

Usually I only use the facebook javascript api, but the login started to bother me, so I try using the PHP api. This is the api call in my header:

<?
require 'stuff/facebook-php/src/facebook.php';

$facebook = new Facebook(array(
  'appId'  => 'my app id',
  'secret' => 'secret',
));

// Get User ID
$user = $facebook->getUser();
?>

I get these messages on my website:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/02/6945202/html/copoetry/index.php:6) in /home/content/02/6945202/html/copoetry/stuff/facebook-php/src/facebook.php on line 37

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/02/6945202/html/copoetry/index.php:6) in /home/content/02/6945202/html/copoetry/stuff/facebook-php/src/facebook.php on line 37

Am I doing something wrong or what could be the problem? Thanks

+5
source share
2 answers

"Could not send session cookie - error headers already sent"

means you printed some data on the page and then tried to set the headers. Headers should be sent before any html output.

and

" cookie - " , UTF-8 WITH BOM Windows. UNIX .

, <?php ?>

+7

, ( ).

?>, , - php-

<?php
require 'stuff/facebook-php/src/facebook.php';

$facebook = new Facebook(array(
  'appId'  => 'my app id',
  'secret' => 'secret',
));

// Get User ID
$user = $facebook->getUser();
+2

All Articles