Facebook Application Development For Dummies - Pdf 11

Jesse Stay
Social media consultant and developer
Learn to:
• Install the Facebook toolkit
and use the Graph API
• Use Facebook Markup Language
and Facebook Query Language
• Create applications for marketing
and making money
• Boost your brand with a Facebook page
Facebook
®
Application
Development
Making Everything Easier!

Open the book and find:
• How to create developer and test
accounts
• Tips for setting up an app-hosting
foundation
• Steps for creating a 5-minute app
• How to recreate your Web site
within Facebook
• Integration points and how to
use them
• Cool ways to use Social Plugins
• How to translate your Web site
into multiple languages
• Pitfalls to avoid
Jesse Stay is a social media technologist, consultant, and developer



Facebook SDK
• Be businesslike — turn app development into a business,
advertise and sell your apps, and keep up with the rules
Facebook
®
Application Development
Stay
www.it-ebooks.info
Start with FREE Cheat Sheets
Cheat Sheets include
• Checklists
• Charts
• Common Instructions
• And Other Good Stuff!
Get Smart at Dummies.com
Dummies.com makes your life easier with 1,000s
of answers on everything from removing wallpaper
to using the latest version of Windows.
Check out our
• Videos
• Illustrated Articles
• Step-by-Step Instructions
Plus, each month you can win valuable prizes by entering
our Dummies.com sweepstakes. *
Want a weekly dose of Dummies? Sign up for Newsletters on
• Digital Photography
• Microsoft Windows & Office
• Personal Finance & Investing

01_9780470768730-ffirs.indd i01_9780470768730-ffirs.indd i 4/4/11 8:48 AM4/4/11 8:48 AM
www.it-ebooks.info
01_9780470768730-ffirs.indd ii01_9780470768730-ffirs.indd ii 4/4/11 8:48 AM4/4/11 8:48 AM
www.it-ebooks.info
by Jesse Stay
Facebook
®
Application
Development
FOR
DUMmIES

01_9780470768730-ffirs.indd iii01_9780470768730-ffirs.indd iii 4/4/11 8:48 AM4/4/11 8:48 AM
www.it-ebooks.info
Facebook
®
Application Development For Dummies
®
Published by
Wiley Publishing, Inc.
111 River Street
Hoboken, NJ 07030-5774
www.wiley.com
Copyright © 2011 by Wiley Publishing, Inc., Indianapolis, Indiana
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or
by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permit-
ted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written
permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the

not be available in electronic books.
Library of Congress Control Number: 2011926323
ISBN: 978-0-470-76873-0
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
01_9780470768730-ffirs.indd iv01_9780470768730-ffirs.indd iv 4/4/11 8:48 AM4/4/11 8:48 AM
www.it-ebooks.info
About the Author
Jesse Stay began his career at age 10 as a developer writing BASIC programs
in his spare time. He would frequently be found copying programs from the
back of 3-2-1 Contact magazines and reading ahead, way ahead, in the books
of his computer programming classes in high school. In third grade, Stay won
third place in his elementary school computer fair, going against the likes of
kids several years older than he was. For his Boy Scout Eagle Scout project,
Stay wrote a computer program in Pascal to help track the blood types of
those in his local church congregation.
At the same time, as an avid entrepreneur, Stay was always looking for the
next way to make money — from the lemonade stands as a kid, to selling
T-shirts from the artwork of others in his high school art class, to his own
lawn-mowing business. He always had a knack for making money “grow on
trees,” something his parents always told him wasn’t possible.
Later on in life, Stay worked under the direction of the VP of marketing at
CWDKids.com. It was there that he was put in charge of helping with the af li-
ate marketing and search engine marketing programs for the company. He
built many scripts in both Perl and VBA to help in this effort. Later, at Media
General (a publishing company, owner of many news organizations through-
out the Southeast), Stay worked to make print classi eds pro table online by
developing creative techniques to help customers  nd what they were look-
ing for. He took that knowledge to BackCountry.com, where he built an inno-
vative ad management platform to build and buy thousands of ads, saving the

Tabernacle Choir on its social strategy, as well as FamilySearch.org, which
has the world’s largest database of linked individuals (Stay proudly calls it
the world’s largest social network). Stay believes  rmly in using “social” tech-
nologies to build fruitful relationships that have a strong effect on the world.
Stay has keynoted for major conferences and has spoken all over the United
States. He has spoken at some of the largest Facebook conferences in the
world, and he loves to share with others how they can learn just a “little
more” to gain that extra edge on Facebook strategy. Stay has spoken and con-
tinues to speak for both business professionals and marketers, and develop-
ers, and has a knack for making both audiences come out enlightened.
In his spare time, Stay likes to play trumpet, work in his garden, hike, moun-
tain bike, and travel the world. Stay speaks  uent Thai and loves interna-
tional culture. Stay has  ve kids and a beautiful wife and, most of all, enjoys
spending time at home with his family.
01_9780470768730-ffirs.indd vi01_9780470768730-ffirs.indd vi 4/4/11 8:48 AM4/4/11 8:48 AM
www.it-ebooks.info
Dedication
To Rebecca, Elizabeth, Thomas, Joseph, Jesse III, and Baby on the way. Without
them, this couldn’t have been possible. I’m especially grateful to my wife, who
has shown great patience in allowing me to spend almost a year writing this, all
while I was working a full-time job, running a company on the side, speaking,
and consulting, along with everything else I do. She keeps me going, and she
continually amazes me how she’s able to support me in everything I do. It is she
who inspires me to keep on pushing harder. She made this possible.
Author’s Acknowledgments
If you’re not included here, I’ve probably thanked you in person already. If
not, I apologize, because it’s impossible to include everyone who made this
possible. Thanks to my family for supporting me along the way. Thanks to my
boss, and those who work with me, for being  exible enough to allow me to
 nish this while working a full-time job (and running a company on the side!).

Development
Sr. Project Editors: Christopher Morris,
Kelly Ewing
Acquisitions Editor: Katie Feltman
Copy Editor: John Edwards
Technical Editor: Allan Carroll
Editorial Manager: Kevin Kirschner
Media Development Project Manager:
Laura Moss-Hollister
Media Development Assistant Project
Manager: Jenny Swisher
Media Development Associate Producers:
Josh Frank, Marilyn Hummel,
Douglas Kuhn, and Shawn Patrick
Editorial Assistant: Amanda Graham
Sr. Editorial Assistant: Cherie Case
Cartoons: Rich Tennant
(www.the5thwave.com)
Composition Services
Project Coordinator: Kristie Rees
Layout and Graphics: Joyce Haughey,
Julie Trippetti
Proofreader: Debbye Butler
Indexer: Ty Koontz
Publishing and Editorial for Technology Dummies
Richard Swadley, Vice President and Executive Group Publisher
Andy Cummings, Vice President and Publisher
Mary Bednarek, Executive Acquisitions Director
Mary C. Corder, Editorial Director
Publishing for Consumer Dummies

Chapter 13: Integrating Facebook into a Mobile Experience 247
Chapter 14: Testing Your Application 271
Part V: Turning Your Facebook Application into
a Legitimate Business 283
Chapter 15: Helping Your Business and Brand Bene t from Facebook 285
Chapter 16: Preparing for the Worst: What Every Facebook Application
Developer Should Know 325
02_9780470768730-ftoc.indd ix02_9780470768730-ftoc.indd ix 4/4/11 8:49 AM4/4/11 8:49 AM
www.it-ebooks.info
Part VI: The Part of Tens 335
Chapter 17: Ten Successful Facebook Applications 337
Chapter 18: Top Ten Facebook Application Development Resources 355
Index 371
02_9780470768730-ftoc.indd x02_9780470768730-ftoc.indd x 4/4/11 8:49 AM4/4/11 8:49 AM
www.it-ebooks.info
Table of Contents
Introduction 1
About This Book 2
Conventions Used in This Book 3
Foolish Assumptions 3
How This Book Is Organized 4
Part I: Understanding the Basics of a Facebook Application 4
Part II: Integrating with the Facebook.com Environment 4
Part III: From Fishers to Farmers — Building Facebook
on Your Own Site 4
Part IV: Delving into APIs 5
Part V: Turning Your Facebook Application into
a Legitimate Business 5
Part VI: The Part of Tens 5
Icons Used in This Book 5

Setting Up Your Hosting Environment 31
Understanding index.html 33
What about my domain? 33
Using existing content or servers 34
Getting the Facebook Developer Application Ready to Go 34
Installing the tools you need 37
Looking around the Developer app 38
Creating Your Own Application in Five Minutes 40
Minute 1: Set up your application 40
Minutes 2–4: Write your application 43
Minute 5: View and test your application 46
Chapter 3: Delving Deeper — Understanding Your Application
and Navigating the Application Setup Process . . . . . . . . . . . . . . . . . . .49
When to Use JavaScript and When to Use the Server
to Access Facebook Platform 49
Using JavaScript: Deciding whether to use XFBML or
pure JavaScript to access Facebook Platform 51
Using the server: Accessing Facebook’s API from
your server in an iFrame environment 54
Understanding the Application Setup Process 55
About 56
Web site 58
Facebook Integration 59
Mobile and Devices 61
Credits 62
Advanced 64
Migrations 66
Part II: Integrating with the Facebook.com
Environment 67
Chapter 4: Targeting Integration Points. . . . . . . . . . . . . . . . . . . . . . . . . .69

Creating a Welcome tab 105
Picking a third-party application 106
Basic Tips Every Page Owner Should Know 106
Part III: From Fishers to Farmers — Building
Facebook on Your Own Site 111
Chapter 6: Turning Your Web Site into a Facebook Page
with Open Graph Protocol and Social Plugins. . . . . . . . . . . . . . . . . . .113
Going the Easy Way with Social Plugins 114
Understanding social plugins 114
Choosing a social plugin 116
The New SEO: Introducing OGP 124
Linking Facebook Users as Admins on Your Web Site 126
Instant Personalization 128
Chapter 7: Integrating Facebook on Your Web Site
through Graph API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131
Understanding the Fundamentals of Graph API 131
Getting data from just a Web browser 133
CRUD! GET’ing versus POST’ing versus DELETE’ing 136
Objects,  elds, and introspection 138
Privacy 141
Setting Up Your Web Site to Use Graph API 143
Setting up your Web site on Facebook 143
Preparing your Web site to use JavaScript 146
Preparing your server to access Facebook using PHP 147
Identifying Your Users 147
Identifying users the more modern way 148
Integrating a Facebook Login button on your site 150
02_9780470768730-ftoc.indd xiii02_9780470768730-ftoc.indd xiii 4/4/11 8:49 AM4/4/11 8:49 AM
www.it-ebooks.info
Facebook Application Development For Dummies

Architecting OAuth 2.0 185
Implementing OAuth 2.0 in a Facebook Environment 187
Taking Shortcuts with OAuth Libraries 189
Authorizing on Your Web Site or in an iFrame Environment 189
Knowing the Future of OAuth 191
OpenID 192
OpenID Connect 192
Chapter 10: Understanding the Essentials — Basic API Calls
Every Developer Should Know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .193
Working with Objects 193
Accessing an object 194
Understanding data returned by objects 195
Getting more data with tokens 196
02_9780470768730-ftoc.indd xiv02_9780470768730-ftoc.indd xiv 4/4/11 8:49 AM4/4/11 8:49 AM
www.it-ebooks.info
xv
Table of Contents
Accessing Data in Objects 196
Accessing an object’s information using JavaScript 197
Accessing an object’s information using PHP 198
Selectively Querying Information with Property Selection 199
Using the IDs parameter to select more than one object 199
Using the  elds parameter to return only certain  elds 201
Using me to return the current user’s info 202
Getting an Object’s Main Picture 202
Accessing an Object’s Connections with Introspection 204
Step 1: Introspecting objects for connections 205
Step 2: Authorizing the user 207
Step 3: Calling the connection URL 207
Step 4: Looping through each connected object 208

02_9780470768730-ftoc.indd xv02_9780470768730-ftoc.indd xv 4/4/11 8:49 AM4/4/11 8:49 AM
www.it-ebooks.info
Facebook Application Development For Dummies
xvi
Chapter 13: Integrating Facebook into a Mobile Experience . . . . . .247
Motivating You with Just a Few Mobile Stats 247
Programming the iOS Facebook SDK 249
Sample project 249
Including the iOS source  les in your project 251
AppDelegate 252
Running the app 257
Programming the Android Facebook SDK 259
Downloading the Facebook Android API 259
Creating your Android project with Facebook API 261
Programming with Facebook, Mobile, and HTML 267
Using the Facebook Places API 269
Chapter 14: Testing Your Application. . . . . . . . . . . . . . . . . . . . . . . . . . .271
Facebook’s API Test Console 271
Facebook’s URL Linter 273
Creating Test Accounts 275
First approach: Manually creating test accounts 275
Second approach: Creating automated test accounts 277
Getting the list of test accounts for your application 280
Friending your test accounts 280
Deleting test accounts 282
Test account restrictions 282
Part V: Turning Your Facebook Application into
a Legitimate Business 283
Chapter 15: Helping Your Business and Brand Benefi t
from Facebook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .285

Improving Site Performance 332
Part VI: The Part of Tens 335
Chapter 17: Ten Successful Facebook Applications. . . . . . . . . . . . . .337
JibJab 337
Huf ngtonPost 339
Pandora 341
Digg.com 342
FamilyLink 344
JumpStart 346
Cinch 348
SocialToo 349
Quora 351
Instagram 353
Chapter 18: Top Ten Facebook Application
Development Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .355
Facebook’s Developer Forum 355
Facebook Application Development For Dummies —
the Facebook Group 358
Facebook Application Development For Dummies —
the Facebook Page 360
Contacting Facebook 362
Facebook Developer Documentation 363
StayNAlive.com 363
MariSmith.com 364
InsideNetwork and InsideFacebook.com 365
AllFacebook.com 366
Facebook Blogs 368
Index 371
02_9780470768730-ftoc.indd xvii02_9780470768730-ftoc.indd xvii 4/4/11 8:49 AM4/4/11 8:49 AM
www.it-ebooks.info

didn’t need to.
Up until now, marketers and developers have had no need to coexist.
Technology made the products, and marketing sold the products. However,
with Facebook and the launch of Facebook Platform in 2007, that all changed.
All of the sudden, technology sold itself, and developers could now also
become marketers, just by writing code. Marketers need to take note!
03_9780470768730-intro.indd 103_9780470768730-intro.indd 1 4/4/11 8:49 AM4/4/11 8:49 AM
www.it-ebooks.info
2
Facebook Application Development For Dummies
About This Book
I wrote this book as a middle ground so that marketers and developers could
come together. I’ve found in the last few years in my speaking and other
engagements that I’ve started to have more and more marketers coming to
me to ask how to properly set up a Facebook tab or to integrate Facebook
into their Web sites. I’ve had many developers come to me to ask how they
can properly promote their products. This book is intended to be an answer
to all those questions.
The truth is, if you’re a marketer or a developer, this book should show you
something. Even if you don’t want to read it from start to finish, you should
be able to pick and choose the elements that look interesting to you, and dis-
cover something from them.
Marketers and developers, by reading this book, may come to understand
each other’s world, at least a little. At the very least, they’ll each feel a little
more inclined to find out about each other’s field, because in an era where
marketing has completely merged with technology, both fields have to learn
a little about each other!
The fact is that Facebook has finally made it possible for developers to
promote their technologies without the need of marketing expertise. In this
book, I show you how.

people who want to know a little more than they should about Facebook. It’s
for those who want to be able to cause a little trouble with what they know.
It’s for those who like to just get things done and not worry about seeing
whether others can get it done for them. I’ve argued back and forth with
my editor on the possibility of just calling this book Hacking Facebook For
Dummies. The truth is, this book is all about hacking Facebook.
If you visit Facebook, the company, you’ll see little stamped “HACK” artwork
on the walls all throughout the company. “Hacking” permeates the culture
of Facebook, from its developers to its marketers to the executives. Mark
Zuckerberg himself, at least I hear, tells his employees to go out and break
things. They have regular “hackathons,” where employees spend all night get-
ting cool things done and building cool products. To be a hacker just means
that you want to get things done and that you’ll use all the tools in your arse-
nal to make that happen. I assume that you’re one of these people, and I’d
like to extend that hack culture to everyone in my audience.
In many cases, I do assume that you at least have a little HTML, and in some
cases, JavaScript knowledge to understand what I’m talking about. If you
don’t, I suggest that you spend some time trying to at least understand what
I’m talking about. You can find other For Dummies books for those topics. Of
course, you can always ask in this book’s Facebook group if you ever have
any questions (stay.am/dummiesgroup).
03_9780470768730-intro.indd 303_9780470768730-intro.indd 3 4/4/11 8:49 AM4/4/11 8:49 AM
www.it-ebooks.info
4
Facebook Application Development For Dummies
How This Book Is Organized
I try to take you through all the different parts of Facebook development in
this book. I try to cover it all. You’ll find that I start out very simple. Toward
the end, I get into a lot more of what you can do with Facebook Platform and
describe how you can integrate it into an application or Web site. You can

Want to really get your hands dirty? This is a part you can’t miss. I show
you all the different things that you can do with Facebook Platform on
Facebook.com itself, or on your own Web site. I introduce you to Graph API
and show you how making a simple request in your browser can reveal infor-
mation about a user.
If you really want to get your hands dirty, I give you examples of how you can
access this information using JavaScript and even PHP. Or, maybe you don’t
want to understand those things. Even so, this part will be interesting for you
to find out what is possible with Facebook Platform.
Part V: Turning Your Facebook Application
into a Legitimate Business
This is the part that can make developers uncomfortable, but I really think
they’ll like this section. I show you how to leverage ads, Facebook Pages,
credits, and more to turn your application into a legitimate business.
As a marketer, you’ll want to read this section to discover what is possible,
and maybe you’ll even find out a few ways to build this stuff yourself, and see
why this is important.
Part VI: The Part of Tens
This is really my favorite section. Here, in each chapter, I give you ten things
that you can discover about specific subjects.
Icons Used in This Book
Where necessary, you see little icons of information that you can either
ignore or pay attention to in order to discover a little bit more about the
subject matter. If anything, it gives you some cute little pictures to look at
instead of just seeing the text.
Wherever you see this cute little Dummies Man head, I leave a little tip that can
make you just one step more knowledgeable about the subject matter. These
are the places you’ll probably find yourself saying, “Hmm, I didn’t realize that!”
03_9780470768730-intro.indd 503_9780470768730-intro.indd 5 4/4/11 8:49 AM4/4/11 8:49 AM
www.it-ebooks.info


Nhờ tải bản gốc
Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status