Did you know? DZone has great portals for Python, Cloud, NoSQL, and HTML5!

John Esposito curates content at DZone, while writing a dissertation on ancient Greek philosophy and raising two cats. In a previous life he was a database developer and network administrator. John is a DZone Zone Leader and has posted 268 posts at DZone. You can read more from them at their website. View Full User Profile

HowTo: Integrate with Facebook from PHP

12.25.2011
Email
Views: 958
  • submit to reddit

Who doesn't want their apps to integrate with Facebook? the second most popular site worldwide, and most popular, bar none, in eight countries (according to Alexa)?

Well, Facebook loves PHP, and even offers a PHP SDK for the Facebook API.

The API is available on Github, with examples -- so browse the SDK directly, if you like.

Or try this new tutorial from phpmaster.com. The author, Hari KT, introduces the guide:

Integrating with Facebook from PHP is easy with the help of Facebook’s PHP SDK and some HTTP libraries like Zend_Http_Client or PEAR HTTP_Request2. In this article I’ll show you how to get started using the Facebook PHP SDK. You’ll learn about the Facebook Graph API and create a Facebook application capable of updating your status message and uploading photos.


Hari runs through initial setup, explains, the Graph API, and provides a sample ('Hello Facebook') application. It looks pretty easy, and could lead to something supremely cool.

Check out the SDK here, and the tutorial here.

Tags:
Published at DZone with permission of its author, John Esposito.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Robert Craft replied on Tue, 2011/12/27 - 10:30am

I made some research and i can't seem to completely undestand how to integrate facebook login with your website. I'm trying to do this for an old fashioned php shop that, up till now, doesn't use any type of login, but only a session that allows users to browse across pages and add items to cart. I read here, on stackoverflow, that you need a table in your database to keep the user's email address and facebook_id. So after that i can hook up with other tables in my db in order to provide info and much more to each user? Are there other ways to easily integrate your website with facebook&google accounts? I read something about OpenID, but didn't really understand what's its use :) So that's why i'm asking you guys to put me on track :). I'm really new with this and any advice, best practices etc.will be greatly appreciated!

John Esposito replied on Tue, 2011/12/27 - 11:33am in response to: robertcraft4

Creating a table with a facebook_id field and an email_address field sounds like it would give you the lookup you need..but maybe I'm not understanding your question. Are you currently using user email addresses to identify users, once they go through the checkout process (since you said that users don't actually login..I'm guessing you ask for email during checkout)?

The Wikipedia page on OpenID is pretty good, I think.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.