Thứ Bảy, 8 tháng 2, 2014

Tài liệu Building Facebook Application For Dummy pdf

About the Author
Richard Wagner is an experienced Web designer and developer as well as
author of several Web-related books. These books include Professional iPhone
and iPod touch Programming, XSLT For Dummies, Creating Web Pages All-in-
One Desk Reference For Dummies, XML All-in-One Desk Reference For
Dummies, Web Design Before & After Makeovers, and JavaScript Unleashed
(1st, 2nd ed.). Before moving into full-time authoring, Richard was vice presi-
dent of product development at NetObjects. He was also inventor and chief
architect of the award-winning NetObjects ScriptBuilder. A versatile author
with a wide range of interests, he is also author of The Myth of Happiness and
C.S. Lewis & Narnia For Dummies.
01_277959-ffirs.qxp 5/5/08 11:23 AM Page iii
01_277959-ffirs.qxp 5/5/08 11:23 AM Page iv
Dedication
To my top Facebook friends, Kim, Jordan, Jared, and Justus.
Author’s Acknowledgments
For this book, I was blessed with a terrific editorial team at Wiley. Thanks go
to Christopher Morris for his steady, flawless management of the book proj-
ect. Thanks also go to Christopher McCulloh for his close attention to all
technical details and helpful suggestions on the coding examples. Further,
thanks to John Edwards and Linda Morris for their keen editing eyes.
01_277959-ffirs.qxp 5/5/08 11:23 AM Page v
Publisher’s Acknowledgments
We’re proud of this book; please send us your comments through our online registration form
located at
www.dummies.com/register/.
Some of the people who helped bring this book to market include the following:
Acquisitions, Editorial, and
Media Development
Sr. Project Editor: Christopher Morris
Acquisitions Editor: Katie Feltman
Copy Editors: John Edwards, Linda Morris
Technical Editor: Christopher McCulloh
Editorial Manager: Kevin Kirschner
Media Development Project Manager:
Laura Moss-Hollister
Media Development Assistant Producer:
Angela Denny
Editorial Assistant: Amanda Foxworth
Sr. Editorial Assistant: Cherie Case
Cartoons: Rich Tennant
(
www.the5thwave.com)
Composition Services
Project Coordinator: Katie Key
Layout and Graphics: Stacie Brooks,
Carl Byers, Reuben W. Davis, Alissa D. Ellet,
Ronald Terry, Christine Williams
Proofreaders: Laura Albert, Debbye Butler,
David Faust
Indexer: Lynnzee Elze
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
Diane Graves Steele, Vice President and Publisher
Joyce Pepple, Acquisitions Director
Composition Services
Gerry Fahey, Vice President of Production Services
Debbie Stailey, Director of Composition Services
01_277959-ffirs.qxp 5/5/08 11:23 AM Page vi
Contents at a Glance
Introduction 1
Part I: Getting Friendly with the Facebook Platform 7
Chapter 1: Introducing Facebook and the Facebook Platform 9
Chapter 2: The App Walkabout: Building Your First Facebook Application 29
Part II: Poking the API 47
Chapter 3: Working with the Facebook API 49
Chapter 4: Writing Facebook Markup Language (FBML) 95
Chapter 5: Exploring FQL: Facebook Query Language 121
Chapter 6: Scripting with Facebook JavaScript 143
Chapter 7: “Goin’ API” with Facebook Developer Tools 167
Part III: Developing Facebook Applications 177
Chapter 8: Developing Facebook Canvas Pages 179
Chapter 9: Creating Content for Profile Pages 195
Chapter 10: Seamless Styles: Styling Your Facebook Application 215
Chapter 11: Hear Ye, Hear Ye: Communicating with
the News Feed and Notifications 235
Chapter 12: Tying It All Together: Speed Dial Application 249
Part IV: The Part of Tens 299
Chapter 13: Ten Strategies to Exploit the Power of the Facebook Platform 301
Chapter 14: Ten Killer Facebook Applications to Explore 313
Chapter 15: Smashing Successes: Ten Tips for Making
Your Application Popular 321
Index 327
02_277959-ftoc.qxp 5/5/08 11:24 AM Page vii
02_277959-ftoc.qxp 5/5/08 11:24 AM Page viii
Table of Contents
Introduction 1
About This Book 1
Foolish Assumptions 2
Conventions Used in This Book 2
What You Don’t Have to Read 3
How This Book Is Organized 3
Part I: Getting Friendly with the Facebook Platform 3
Part II: Poking the API 3
Part III: Developing Facebook Applications 4
Part IV: The Part of Tens 4
Icons Used in This Book 4
Where to Go from Here 5
Sample Files for This Book 5
Part I: Getting Friendly with the Facebook Platform 7
Chapter 1: Introducing Facebook and the Facebook Platform . . . . . . .9
Discovering Facebook 10
News Feed 10
Profile 12
Discovering the Pulse of Facebook: The Social Graph 15
What Is the Facebook Platform? 16
Points of integration 16
Facebook application architecture 22
Exploring the Framework Components 24
Facebook API 24
Facebook Markup Language 25
Facebook Query Language 25
Facebook JavaScript 26
Chapter 2: The App Walkabout: Building Your
First Facebook Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29
Registering an Application with Facebook 30
Creating a Simple Facebook Application 37
Adding an Icon to the Application 41
Setting the Initial Content of the Application’s Profile Box 42
Adding an About Page 43
02_277959-ftoc.qxp 5/5/08 11:24 AM Page ix
Part II: Poking the API 47
Chapter 3: Working with the Facebook API . . . . . . . . . . . . . . . . . . . . . .49
Calling the Facebook API 49
Evaluating What Comes Back from Facebook 55
Getting Friendly with Friends 56
Getting friends with friends.get 57
Evaluating friends with friends.areFriends 58
Getting friends who are app users with friends.appUsers 60
Accessing Events 62
Getting the events of a user 62
Getting the members of an event 69
Getting Cozy with Groups 72
Getting groups with groups.get 73
Retrieving member info with groups.getMembers 80
Facebook Pages 83
Getting page information with pages.getInfo 84
Scoping out with pages.isAppAdded 86
Getting current user info with pages.isAdmin and pages.isFan 87
Pulling User Data 87
Getting the current user with users.getLoggedInUser 87
Getting info with users.getInfo 88
Checking whether a user has your app with users.isAppAdded 93
Checking permissions with users.hasAppPermissions 93
Chapter 4: Writing Facebook Markup Language (FBML) . . . . . . . . . . .95
Exploring FBML 95
Working with Users and Groups 103
Displaying Content Conditionally 106
Testing on canvas pages 107
Showing and hiding content in profile boxes 109
Using fb:if and fb:switch 111
Adding Facebook UI Elements and Widgets 112
Discussing it on the board 113
Another comment on the Wall 114
Building a Wall post by post 115
Creating Requests and Invitations 116
Building a standard-sized request form 116
Building a condensed request form 120
Chapter 5: Exploring FQL: Facebook Query Language . . . . . . . . . . . .121
Discovering Why SQL + Facebook API = FQL 121
Comparing FQL and API access 122
Making an FQL statement 123
Differences between SQL and FQL 123
Building Facebook Applications For Dummies
x
02_277959-ftoc.qxp 5/5/08 11:24 AM Page x
Writing a Basic Query 124
Changing the field order in the result set 127
Dealing with array-type fields 128
Using operators in the WHERE clause 128
Writing More Complex Queries with the IN Operator 129
Using Special Functions 139
Chapter 6: Scripting with Facebook JavaScript . . . . . . . . . . . . . . . . .143
Understanding the Facebook Platform Scripting Approach 143
Accessing the DOM 144
Setting the Content of DOM Elements 147
setInnerXHTML() 147
setInnerFBML() 147
setInnerText() 148
Setting Styles through FBJS 148
Including External JavaScript Files on Canvas Pages 149
Helpful Tips When Using FBJS 150
Using the FBJS Animation Library 150
Tweening animation 152
Adjusting the speed and ease of the animation 156
Adjusting the size and visibility of block-level events 156
Working with AJAX in FBJS 159
Chapter 7: “Goin’ API” with Facebook Developer Tools . . . . . . . . . .167
Working with the API Test Console 168
FBML Test Console 170
Feed Preview Console 173
Debugging FBJS with Firebug 176
Part III: Developing Facebook Applications 177
Chapter 8: Developing Facebook Canvas Pages . . . . . . . . . . . . . . . . .179
To FBML or iframe? That Is the Question 179
Adding a Navigation Header Using FBML 181
Adding an fb:dashboard element 183
Adding a tab set with fb:tabs and fb:tab-item 185
Adding a header with fb:header 188
Creating an Editor Form Page 190
Chapter 9: Creating Content for Profile Pages . . . . . . . . . . . . . . . . . . .195
Discovering Profile Boxes and Action Links 195
Profile box 196
Profile action links 197
Configuring the Default Profile Settings 198
xi
Table of Contents
02_277959-ftoc.qxp 5/5/08 11:24 AM Page xi
Pushing Profile Content with profile.setFBML 199
Working with Content in the Profile Box 201
Adding Action Links to a User Profile 212
Chapter 10: Seamless Styles: Styling Your
Facebook Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .215
Adding Styles to Your FBML 215
Using inline styles 216
Using embedded styles 216
Including external style sheets 218
Specifying Wide and Narrow Styles for Profile Boxes 218
Using fb:ref to Load CSS in a Profile Box 219
Going Native: Emulating Facebook Styles 220
Setting the basic formatting styles 221
Emulating the Facebook dashboard 223
Creating your own navigation tabs 226
Creating a subtitle region 228
Emulating Facebook buttons 229
Creating two-column lists 232
Chapter 11: Hear Ye, Hear Ye: Communicating with
the News Feed and Notifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .235
Publishing a News Feed Story to Current Users 236
Publishing Actions to a User’s Mini-Feed and Friends’ News Feed 238
Rolling Up Your Sleeves: Publishing Templatized Actions 240
Exploring the template parameters 241
Working with tokens 242
Exploring the fbRecipe template 244
Registering your story template 245
Sending Notifications 247
Chapter 12: Tying It All Together: Speed Dial Application . . . . . . . . .249
Coming Up with a Basic Vision 249
Setting Up Speed Dial in Facebook 250
Creating the Speed Dial Database 253
Structuring the PHP Source Code 254
Setting Up the Canvas Page 254
Connecting to Facebook 255
Building the Canvas Page 256
Constructing the page header 257
Adding a friend 258
Getting a list of dial friends 259
Previewing the Speed Dial 260
Resetting the Speed Dial 262
Processing user actions 262
Building Facebook Applications For Dummies
xii
02_277959-ftoc.qxp 5/5/08 11:24 AM Page xii

Không có nhận xét nào:

Đăng nhận xét