Cannot get a session with Facebook app? (using its Graph API)

Posted by Jian Lin on Stack Overflow See other posts from Stack Overflow or by Jian Lin
Published on 2010-05-08T20:26:48Z Indexed on 2010/05/11 1:04 UTC
Read the original article Hit count: 434

I have really simple few lines of Facebook app, using the new Facebook API:

<pre>

<?php

require 'facebook.php';

// Create our Application instance.
$facebook = new Facebook(array(
  'appId'  => '117676584930569',
  'secret' => '**********',                 // hidden here on the post...
  'cookie' => true,
));

var_dump($facebook);

?>

but it is giving me the following output:

http://apps.facebook.com/woolaladev/i2.php would give out

object(Facebook)#1 (6) {
  ["appId:protected"]=>
  string(15) "117676584930569"
  ["apiSecret:protected"]=>
  string(32) "**********"                   <--- just hidden on this post
  ["session:protected"]=>
  NULL                                      <--- Session is NULL for some reason
  ["sessionLoaded:protected"]=>
  bool(false)
  ["cookieSupport:protected"]=>
  bool(true)
  ["baseDomain:protected"]=>
  string(0) ""
}

Session is NULL for some reason, but I am logged in and can access my home and profile and run other apps on Facebook (to see that I am logged on).

I am following the sample on:

http://github.com/facebook/php-sdk/blob/master/examples/example.php
http://github.com/facebook/php-sdk/blob/master/src/facebook.php

(download using raw URL: wget http://github.com/facebook/php-sdk/raw/master/src/facebook.php )

Trying on both hosting companies at dreamhost.com and netfirms.com, and the results are the same.

© Stack Overflow or respective owner

Related posts about facebook

Related posts about authentication