views:

599

answers:

2

Hello,

I have an iPhone app which creates a facebook session and I would like to restore this session on my server to hand off some of the work. I have the iPhone app working perfectly fine, it's just that I am having problems restoring the session - the documentation is lacking, at best (from http://wiki.developers.facebook.com/index.php/Facebook%5FConnect%5Ffor%5FiPhone -"If you want to call the API from your servers, you just need to get the sessionKey and sessionSecret properties from the session and send them back to your servers", that's it).

I think I have a decent start from what docs I have found, and my php page looks like:

require_once 'facebook.php';
$appapikey = 'key';
$appsecret = 'secret';
$userid = 'id';
$sessionKey = 'key';
$facebook = new Facebook($appapikey, $appsecret);
$facebook->set_user($userid,$sessionKey);

However, when I try to login to this page I get the following error:

Fatal error: Uncaught exception 'FacebookRestClientException' with message 'Session key invalid or no longer valid'

I know that the session is valid because I am still logged in on my iPhone app. Does anybody know how to restore a session that was started on Facebook Connect?

Thank you

A: 

I have the same issue. I want to authenticate Facebook access on the iPhone, but then allow my server to post to Facebook.

Anybody know anything about this? I tried posting to Facebook's forum, but no response.

Greg Maletic
+1  A: 

i spent a lot of time to find answer but found it already:

$this->facebook = new Facebook($appapikey, $appsecret);
$this->facebook->set_user($fb_id, $sessionKey, null, $sessionSecret); 

just post sessionSecret with sessionKey to your server and use it with set_user API method

works perfect for me :)

sdlugosz