Facebook iOS: Use Access Token in PHP

Yes that's right. As of the time of this writing, it is possible to use the user granted access_token back in some server side scripting language like PHP. If you currently have a 255 varchar field size for access_tokens in your database, you may want to bump that up a bit.

The time I made the sample code ran and allowed me to log in (one that came bundled with the Facebook iOS SDK from GitHub), I began realizing that the token quite have different format than the one we usually see in web-based apps (e.g. FB iFrame app).

The usual token looks something like this:


..while in mobile:


The plan was, allow users to connect to our application using FB. Then once he approved it, we take a copy of the access_token and save it back to the server. Same access_token will be used once he logs in to his account using our web-based app.

Well, so far so good. Let me know if yours doesn't work.

Related posts:


Magento Modules said...

thanks, can we use same for Magento?

Magento Themes said...

Great idea, will also check on it..

Magento Themes said...

can it be done through database....

bassgrinder said...

Well yes. But that was then when offline_access was still available. Things are different now on this. And you should read the following article and know the things you can do to extend the life of these tokens.

Read on Removal of offline_access permission here: http://developers.facebook.com/roadmap/offline-access-removal/

bassgrinder said...

Can you use the same for Magento? Well yah. I see no problem adopting it to your web app. Just be aware of the current Facebook trends because every now and then, they change stuffs in their platform.

Post a Comment

Hi there! Please leave your message here. Also, I may not be able to respond to your query right away. So please bear with me. Thanks. :)