Comments on: Facebook iPhone Session Proxy in PHP (FBSession getSessionProxy) http://www.performantdesign.com/2009/09/03/facebook-iphone-session-proxy-in-php-fbsession-getsessionproxy/ Mon, 08 Aug 2011 19:00:37 -0400 http://wordpress.org/?v=2.8.4 hourly 1 By: Sid Ahuja http://www.performantdesign.com/2009/09/03/facebook-iphone-session-proxy-in-php-fbsession-getsessionproxy/comment-page-1/#comment-5257 Sid Ahuja Thu, 23 Sep 2010 02:35:20 +0000 http://www.performantdesign.com/?p=138#comment-5257 Thanks! This saved me a lot of time. You're awesome to have posted this solution. God bless you Thanks! This saved me a lot of time. You’re awesome to have posted this solution. God bless you

]]>
By: Mark http://www.performantdesign.com/2009/09/03/facebook-iphone-session-proxy-in-php-fbsession-getsessionproxy/comment-page-1/#comment-2114 Mark Wed, 11 Nov 2009 23:10:13 +0000 http://www.performantdesign.com/?p=138#comment-2114 The video I mentioned - pretty iPhone specific, and all iPhone developers will immediately find it, but in case someone is frustrated at reading the above and not having a link: http://www.vimeo.com/3616452 The video I mentioned – pretty iPhone specific, and all iPhone developers will immediately find it, but in case someone is frustrated at reading the above and not having a link:

http://www.vimeo.com/3616452

]]>
By: Mark http://www.performantdesign.com/2009/09/03/facebook-iphone-session-proxy-in-php-fbsession-getsessionproxy/comment-page-1/#comment-2113 Mark Wed, 11 Nov 2009 23:09:02 +0000 http://www.performantdesign.com/?p=138#comment-2113 Update: after I set it up end-to-end, it is working. I didn't have to do any further changes to the script, and I followed pretty much the instructions in the short iPhone FBConnect video. Moral of the story: FB isn't really big on giving you ways to test individual components; you have to do big-bang development and then hope everything works at the end. Update: after I set it up end-to-end, it is working. I didn’t have to do any further changes to the script, and I followed pretty much the instructions in the short iPhone FBConnect video. Moral of the story: FB isn’t really big on giving you ways to test individual components; you have to do big-bang development and then hope everything works at the end.

]]>
By: aaron http://www.performantdesign.com/2009/09/03/facebook-iphone-session-proxy-in-php-fbsession-getsessionproxy/comment-page-1/#comment-2112 aaron Wed, 11 Nov 2009 22:23:32 +0000 http://www.performantdesign.com/?p=138#comment-2112 The auth_token is generated by Facebook and automatically passed by them... In short, you'll more or less need a working iPhone app to test. Wish there were a simpler way, but can't provide any pointers on that... In regards to the web vs. desktop setting, desktop should be the moral equivalent of an iPhone app - so unless you also have a web app to supplement the iPhone app, the desktop setting should be sufficient. Good luck! Hope this all helps once the app is ready. The auth_token is generated by Facebook and automatically passed by them… In short, you’ll more or less need a working iPhone app to test. Wish there were a simpler way, but can’t provide any pointers on that…

In regards to the web vs. desktop setting, desktop should be the moral equivalent of an iPhone app – so unless you also have a web app to supplement the iPhone app, the desktop setting should be sufficient.

Good luck! Hope this all helps once the app is ready.

]]>
By: Mark http://www.performantdesign.com/2009/09/03/facebook-iphone-session-proxy-in-php-fbsession-getsessionproxy/comment-page-1/#comment-2111 Mark Wed, 11 Nov 2009 22:20:15 +0000 http://www.performantdesign.com/?p=138#comment-2111 Oops, in my URL in previous post after auth_token= it had a placeholder for my API key, but I wrote it (for the post) inside less-than/greater than, so it didn't show up in my post. Trying again: http://www.mydomain.com/scriptname.php?auth_token={my_app_api_id_here}&generate_session_secret=1 Oops, in my URL in previous post after auth_token= it had a placeholder for my API key, but I wrote it (for the post) inside less-than/greater than, so it didn’t show up in my post.

Trying again:
http://www.mydomain.com/scriptname.php?auth_token={my_app_api_id_here}&generate_session_secret=1

]]>
By: Mark http://www.performantdesign.com/2009/09/03/facebook-iphone-session-proxy-in-php-fbsession-getsessionproxy/comment-page-1/#comment-2110 Mark Wed, 11 Nov 2009 22:17:21 +0000 http://www.performantdesign.com/?p=138#comment-2110 Thanks for replying. Here's my theory for what my problem is. I don't have the first clue about PHP, so I was running the PHP script from the command line with php scriptname.php, and expecting it to work. After digging into PHP a bit I see that $_GET is populated from the values set in an incoming http request, so it won't contain anything if the script is run from the command line. Basic web 101 developer mistake type stuff. So for now I'm just hoping it's working; I will only be able to verify it once I get it all coded up end-to-end in the app. Was hoping I could just try out the script but no such luck. Also tried it in a web browser with http://www.mydomain.com/scriptname.php?auth_token=&generate_session_secret=1 but that still gave an error: Fatal error: Uncaught exception 'FacebookRestClientException' with message 'Invalid parameter' in /somepath/fb/facebook-platform/php/facebookapi_php5_restlib.php:3112 Stack trace: #0 /somepath/fb/facebook-platform/php/facebookapi_php5_restlib.php(309): FacebookRestClient->call_method('facebook.auth.g...', Array) #1 /somepath/fb/auth-proxy.php(18): FacebookRestClient->auth_getSession('e56974405663778...', '1') #2 {main} thrown in /somepath/fb/facebook-platform/php/facebookapi_php5_restlib.php on line 3112 Maybe there are other parameters that are set under the hood when the call is made from the iPhone client library. Re: your questions, Sandbox mode is not on. As to the callback URL, I'm not sure why the choices are only web and desktop. I'm trying to add FBConnect to an iPhone app. Mine was set to web but I changed it to desktop now, and that hasn't helped. Changes to the script: it's as-is, except for my app's api key and secret, and I changed the require line to point to the facebook.php file on my system, which resides in the untarred folder with the other FBConnect library files. Thanks for replying.

Here’s my theory for what my problem is. I don’t have the first clue about PHP, so I was running the PHP script from the command line with php scriptname.php, and expecting it to work. After digging into PHP a bit I see that $_GET is populated from the values set in an incoming http request, so it won’t contain anything if the script is run from the command line. Basic web 101 developer mistake type stuff.

So for now I’m just hoping it’s working; I will only be able to verify it once I get it all coded up end-to-end in the app. Was hoping I could just try out the script but no such luck.

Also tried it in a web browser with http://www.mydomain.com/scriptname.php?auth_token=&generate_session_secret=1 but that still gave an error:

Fatal error: Uncaught exception ‘FacebookRestClientException’ with message ‘Invalid parameter’ in /somepath/fb/facebook-platform/php/facebookapi_php5_restlib.php:3112 Stack trace: #0 /somepath/fb/facebook-platform/php/facebookapi_php5_restlib.php(309): FacebookRestClient->call_method(’facebook.auth.g…’, Array) #1 /somepath/fb/auth-proxy.php(18): FacebookRestClient->auth_getSession(’e56974405663778…’, ‘1′) #2 {main} thrown in /somepath/fb/facebook-platform/php/facebookapi_php5_restlib.php on line 3112

Maybe there are other parameters that are set under the hood when the call is made from the iPhone client library.

Re: your questions, Sandbox mode is not on.

As to the callback URL, I’m not sure why the choices are only web and desktop. I’m trying to add FBConnect to an iPhone app. Mine was set to web but I changed it to desktop now, and that hasn’t helped.

Changes to the script: it’s as-is, except for my app’s api key and secret, and I changed the require line to point to the facebook.php file on my system, which resides in the untarred folder with the other FBConnect library files.

]]>
By: aaron http://www.performantdesign.com/2009/09/03/facebook-iphone-session-proxy-in-php-fbsession-getsessionproxy/comment-page-1/#comment-2109 aaron Wed, 11 Nov 2009 21:17:49 +0000 http://www.performantdesign.com/?p=138#comment-2109 There are a lot of different settings that might be throwing things off... On the advanced settings tab for the app, you might want to look at a few things. Is sandbox mode on? If so, maybe turn it off. What do you have the application type set to? For this app in particular - for various reasons - I used web, but you may want to use desktop. If you use web, a canvas callback url is required on the canvas tab. If you use desktop, that's not needed. Are you using the script above as-is (only changing the api key and session secret), or were other changes made? There are a lot of different settings that might be throwing things off… On the advanced settings tab for the app, you might want to look at a few things. Is sandbox mode on? If so, maybe turn it off. What do you have the application type set to? For this app in particular – for various reasons – I used web, but you may want to use desktop. If you use web, a canvas callback url is required on the canvas tab. If you use desktop, that’s not needed.

Are you using the script above as-is (only changing the api key and session secret), or were other changes made?

]]>
By: Mark http://www.performantdesign.com/2009/09/03/facebook-iphone-session-proxy-in-php-fbsession-getsessionproxy/comment-page-1/#comment-2108 Mark Wed, 11 Nov 2009 21:03:56 +0000 http://www.performantdesign.com/?p=138#comment-2108 OK, not only does Brent's (official FB) example not work for me, the performant design one included above also gives me an Invalid parameter error. But at least in the latter case the error is in nice XML format! Cool! Now if I could figure out why I'm still getting the error... OK, not only does Brent’s (official FB) example not work for me, the performant design one included above also gives me an Invalid parameter error. But at least in the latter case the error is in nice XML format! Cool! Now if I could figure out why I’m still getting the error…

]]>
By: Mark http://www.performantdesign.com/2009/09/03/facebook-iphone-session-proxy-in-php-fbsession-getsessionproxy/comment-page-1/#comment-2107 Mark Wed, 11 Nov 2009 20:56:53 +0000 http://www.performantdesign.com/?p=138#comment-2107 Brent, I've been trying your new session proxy, and it's not working for me at all. I have my api_key and secret set correctly and I'm still getting Invalid parameter errors. Maybe you've done something with the setup of your application on the Facebook side that isn't well documented. Do I need to set the callback URL? Should it be pointing to the URL of my proxy PHP script? What about the other URL? (mine is empty atm). Are there other settings that are required to make this work? Someone on the docs team there at FB should sit down with a new developer and watch them walk through the process using only the doc that is provided at http://wiki.developers.facebook.com/index.php/Facebook_Connect_for_iPhone I think you will see that there are problems with the doc. We are not psychic and we do not know what settings you have done that are not documented in order to get your app working. Fatal error: Uncaught exception 'FacebookRestClientException' with message 'Invalid parameter' in /fake-path-for-this-post/fb/facebook-platform/php/facebookapi_php5_restlib.php:3112 Stack trace: #0 /fake-path-for-this-post/fb/facebook-platform/php/facebookapi_php5_restlib.php(309): FacebookRestClient->call_method('facebook.auth.g...', Array) #1 /fake-path-for-this-post/fb/auth-proxy.php(17): FacebookRestClient->auth_getSession(NULL, NULL) #2 {main} thrown in /fake-path-for-this-post/fb/facebook-platform/php/facebookapi_php5_restlib.php on line 3112 Brent,

I’ve been trying your new session proxy, and it’s not working for me at all. I have my api_key and secret set correctly and I’m still getting Invalid parameter errors.

Maybe you’ve done something with the setup of your application on the Facebook side that isn’t well documented. Do I need to set the callback URL? Should it be pointing to the URL of my proxy PHP script? What about the other URL? (mine is empty atm). Are there other settings that are required to make this work?

Someone on the docs team there at FB should sit down with a new developer and watch them walk through the process using only the doc that is provided at http://wiki.developers.facebook.com/index.php/Facebook_Connect_for_iPhone

I think you will see that there are problems with the doc. We are not psychic and we do not know what settings you have done that are not documented in order to get your app working.

Fatal error: Uncaught exception ‘FacebookRestClientException’ with message ‘Invalid parameter’ in /fake-path-for-this-post/fb/facebook-platform/php/facebookapi_php5_restlib.php:3112
Stack trace:
#0 /fake-path-for-this-post/fb/facebook-platform/php/facebookapi_php5_restlib.php(309): FacebookRestClient->call_method(’facebook.auth.g…’, Array)
#1 /fake-path-for-this-post/fb/auth-proxy.php(17): FacebookRestClient->auth_getSession(NULL, NULL)
#2 {main}
thrown in /fake-path-for-this-post/fb/facebook-platform/php/facebookapi_php5_restlib.php on line 3112

]]>
By: Brent Goldman http://www.performantdesign.com/2009/09/03/facebook-iphone-session-proxy-in-php-fbsession-getsessionproxy/comment-page-1/#comment-2040 Brent Goldman Wed, 21 Oct 2009 00:51:28 +0000 http://www.performantdesign.com/?p=138#comment-2040 I'm an engineer at Facebook on the Connect team. I want to correct a couple misconceptions with this post, as well as provide an alternative solution that allows you to work within the framework of the PHP client library instead of creating a new PHP Facebook wrapper. The reason the call to auth.getSession is failing has nothing to do with the empty session key. The problem relates to some magic that Facebook's PHP client library does with the GET params and cookies during initialization. Specifically,if $_GET['auth_token'] is set, the Facebook PHP lib will call do_get_session(), which automagically calls auth.getSession on your behalf. This first call to auth.getSession (the automatic one) will "use up" the auth_token, invalidating it for future use. The second call to auth.getSession (the one you're explicitly making) will then fail as a result. The "Invalid parameter" specifically refers to the invalid auth_token. I just wrote a new session proxy, made sure it worked on my test iPhone app, and then uploaded it to the wiki. Feel free to use this and suggest improvements. http://wiki.developers.facebook.com/index.php/Session_Proxy I’m an engineer at Facebook on the Connect team. I want to correct a couple misconceptions with this post, as well as provide an alternative solution that allows you to work within the framework of the PHP client library instead of creating a new PHP Facebook wrapper.

The reason the call to auth.getSession is failing has nothing to do with the empty session key. The
problem relates to some magic that Facebook’s PHP client library does with the
GET params and cookies during initialization. Specifically,if $_GET['auth_token'] is set, the Facebook PHP lib will call do_get_session(), which automagically calls auth.getSession on your behalf. This first call to auth.getSession (the automatic one) will “use up” the auth_token, invalidating it for future use. The second call to auth.getSession (the one you’re explicitly making) will then fail as a result. The “Invalid parameter” specifically refers to the invalid auth_token.

I just wrote a new session proxy, made sure it worked on my test iPhone app, and then
uploaded it to the wiki. Feel free to use this and suggest improvements.
http://wiki.developers.facebook.com/index.php/Session_Proxy

]]>