Adding Facebook SDK as Application Component

I’ve seen a couple of topics on the forum from earlier this year about Facebook integration but they seem to pre-date the newer Facebook PHP library + graph API.

I’m developing a application (iFrame) and I’m in two minds about how to proceed. I’ve created some basic functionality including a User model that will just persist the Facebook UID to my DB (along with a couple of other fields). I understand about modifying UserIdentity’s authentication scheme to suit my needs as well as implementing some basic login controllers and actions.

From people’s work previously I’ve seen them extend and/or modify Controllers and manage Facebook sessions and authentication there, but it seems that implementing Facebook’s PHP library wrapped as an application component makes more sense. I can preload it and as part of the initialization do some basic checking for existing Facebook sessions and then hand off to LoginControllers and UserIdentities. It’s accessible then through Yii::app()->facebook for Graph API lookups (e.g. facebook->api(’/me’)).

Is this a decent approach or am I overlooking something like session expiry/security?

Hi there, I too am building a facebook app using Yii. It took me a while to figure it out, but I have adapted earlier forum posts where the siteController inherits from the HFacebook class. It seams to be working for me. I simply try to get a facebook session on the indexAction in sitecontroller, and if this fails, redirect the user to the login page.

I have also been successful in integrating the faceconn php library - which allowed me to insert an invite feature in under an hour.

I know that maybe this post never answered many of your questions, but wanted to let you know that I am also developing facebook with Yii. So far, I am pretty happy with the framework.

ps - please keep me updated with your progress as will I

my app will have FB integration aswell is a later stage, i’m very much interested to hear how you guys work around it

Personally, I went with FacebookController and pointed the iFrame’s source URL there after defining actionIndex(), which checks/initiates the FB session and then renders the canvas view. Works for me. One advantage I see to doing it your way is the easy access to the API using just [color="#0000FF"][font=“Courier New”]Yii::app()->facebook[/font][/color], I like that.

is the one in the ps-yii-extensions package any good?

That package is not up-to-date. If you follow the repo through to it’s current home, the code there is unusable. I’m not sure if this is just due to the code being rewritten again, or if it’s simply broken.

You’ll be better off developing your own solution until someone posts an alternative.