0321680774.Pdf

0321680774.Pdf

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 [email protected] For sales outside the United States please contact: International Sales [email protected] Visit us on the Web: informit.com/aw Library of Congress Cataloging-in-Publication Data: Hawker, Mark D. The developer’s guide to social programming : building social context using Facebook, Google friend connect, and the Twitter API / Mark D. Hawker. p. cm. ISBN 978-0-321-68077-8 (pbk. : alk. paper) 1. Online social networks. 2. Entertainment computing. 3. Internet programming. 4. Google. 5. Facebook (Electronic resource) 6. Twitter. I. Title. HM742.H39 2010 006.7’54—dc22 2010020866 Copyright © 2011 Pearson Education, Inc. All rights reserved. Printed in the United States of America. This publication is protected by copy- right, and permission must be obtained from the publisher prior to any prohibited reproduction, stor- age in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, write to: Pearson Education, Inc Rights and Contracts Department 501 Boylston Street, Suite 900 Boston, MA 02116 Fax (617) 671 3447 ISBN-13: 978-0-321-68077-8 ISBN-10: 0-321-68077-4 Text printed in the United States on recycled paper at RR Donnelley Crawfordsville in Crawfordsville, Indiana. First printing, August 2010 Contents at a Glance I: Twitter 1 Working with the Twitter API 1 2 Diving Into the Twitter API Methods 21 3 Authentication with Twitter OAuth 45 4 Extending the Twitter API: Retweets, Lists, and Location 61 II: Facebook Platform 5 An Overview of Facebook Platform Website Integration 77 6 Registration, Authentication, and Translations with Facebook 99 7 Using Facebook for Sharing, Commenting, and Stream Publishing 115 8 Application Discovery, Tabbed Navigation, and the Facebook JavaScript Library 137 III: Google Friend Connect 9 An Overview of Google Friend Connect 165 10 Server-Side Authentication and OpenSocial Integration 193 11 Developing OpenSocial Gadgets with Google Friend Connect 209 IV: Putting It All Together 12 Building a Microblog Tool Using CodeIgniter 235 13 Integrating Twitter, Facebook, and Google Friend Connect 267 Table of Contents I: Twitter 1 Working with the Twitter API 1 Twitter API Essentials 1 Twitter API Methods 3 Twitter API Parameters 6 Twitter API Return Formats 10 Accessing the Twitter API 11 cURL 12 Twitter-async 14 Twitter API Rate Limiting 17 Twitter API Error Handling 18 Summary 19 2 Diving Into the Twitter API Methods 21 Twitter API Methods 21 User Objects 23 Status Objects 26 Direct Message Objects 28 Saved Search Objects 29 ID Objects 30 Relationship Objects 31 Response Objects 32 Hash Objects 33 Twitter Search API 34 Introducing the Atom Syndication Format 34 Twitter Search API Methods 38 Summary 43 3 Authentication with Twitter OAuth 45 Introducing Twitter OAuth 45 OAuth Benefits 46 OAuth Definitions 46 viii Contents Implementing Twitter OAuth 48 Twitter OAuth Workflow 48 Test Tube: A Sample Twitter Application 50 Summary 59 4 Extending the Twitter API: Retweets, Lists, and Location 61 Extending Twitter’s Core Functionality 61 Retweet API 62 Lists API 64 Geolocation API 68 Twitter Community Evolution 71 Platform Translations 71 Spam Reporting 72 Future Directions 74 Summary 76 II: Facebook Platform 5 An Overview of Facebook Platform Website Integration 77 Facebook Platform for Developers 77 Facebook Platform 78 Registering a Facebook Application 79 Referencing a Facebook Platform Application 81 Facebook API, FQL, and XFBML 84 Facebook API and FQL 84 XFBML 97 Summary 98 6 Registration, Authentication, and Translations with Facebook 99 User Authorization and Authentication 99 Logging In and Detecting Facebook Status 101 Logging Out, Disconnecting, and Reclaiming Accounts 107 Contents ix Connecting and Inviting Friends 109 Translations for Facebook 111 Preparing Your Application and Registering Text 111 Administering and Accessing Translations 113 Summary 114 7 Using Facebook for Sharing, Commenting, and Stream Publishing 115 Content-Sharing and Live Conversation 115 Facebook Share 116 Facebook Widgets 118 Social Commenting and Stream Publishing 120 Comments Box 120 Open Stream API 123 Summary 135 8 Application Discovery, Tabbed Navigation, and the Facebook JavaScript Library 137 Application Dashboards and Counters 138 News and Activity Streams 139 Games and Applications Counters 143 Navigating and Showcasing Your Application Using Tabs 145 Configuring and Installing an Application Tab 146 Extending an Application Tab 149 Dynamic Content and the Facebook JavaScript (FBJS) Library 157 Facebook Animation Library 157 Facebook Dialogs 160 Handling Events with an Event Listener 162 Summary 164 III: Google Friend Connect 9 An Overview of Google Friend Connect 165 Components of Google Friend Connect 165 Google Friend Connect Gadgets 166 x Contents Google Friend Connect JavaScript API 167 Server-Side Integration 167 Google Friend Connect Plug-ins 168 Using the Google Friend Connect JavaScript API 169 Installing and Configuring the JavaScript Library 169 Working with Google Friend Connect Data 171 An Overview of the OpenSocial API 173 OpenSocial API Methods 173 The DataRequest Object 174 Fetching People and Profiles 176 Fetching and Updating Activities 177 Fetching and Updating Persistence 178 Color Picker: A Google Friend Connect Application 181 Summary 191 10 Server-Side Authentication and OpenSocial Integration 193 Server-Side OpenSocial Protocols and Authentication Methods 193 Google Friend Connect Authentication Methods 194 OpenSocial Client Libraries 196 Using the PHP OpenSocial Client Library with Google Friend Connect 197 Google Friend Connect Authentication Workflow 197 Setting Up a Server-Side Application 198 OpenSocial Data Extraction Principles 201 Summary 207 11 Developing OpenSocial Gadgets with Google Friend Connect 209 An Overview of Google Gadgets 209 Anatomy of an OpenSocial Google Gadget 210 OpenSocial v0.9 Specification 214 Advanced OpenSocial Gadget Development 217 Creating a Google Gadget 222 Color Picker, Revisited 222 Testing, Tracking, and Directory Submission 230 Summary 233 Contents xi IV: Putting It All Together 12 Building a Microblog Tool Using CodeIgniter 235 An Overview of CodeIgniter 235 The Model-View-Controller Architectural Design 236 Installing, Configuring, and Exploring CodeIgniter 237 CodeIgniter Libraries 240 CodeIgniter Helpers 245 Building the Basic Sprog Application 246 Stage 1: Creating the Registration, Login, and Home Pages 247 Stage 2: Extending the Sprog Application with Updates, Comments, and Likes 257 Summary 266 13 Integrating Twitter, Facebook, and Google Friend Connect 267 Implementing Twitter Functionality 267 Setting Up Twitter and Twitter-async Support 268 Stage 3: Extending the Sprog Application with Twitter Functionality 270 Updating a User’s Twitter Account 276 Implementing Facebook Functionality 279 Registering a Facebook Application and Adding Facebook Support 279 Stage 4: Extending the Sprog Application with Facebook Functionality 281 Implementing Google Friend Connect Functionality 292 Registering and Adding Google Friend Connect Support 292 Stage 5: Extending the Sprog Application with Google Friend Connect Functionality 294 Summary 301 Index 303 Preface The World Wide Web is in constant flux and, since the introduction of utilities such as Facebook and Twitter, has only recently had social interaction at its core. Currently, Facebook and Twitter have more than 400 million active users, and the Facebook Platform alone is integrated with more than 250,000 websites and applications, engaging over 100 million Facebook users each month.These numbers continue to increase each day.Another dominant force is Google, who introduced their Friend Connect, which enables users to add social functionality to any of their websites.All three companies continue to roll out massive changes to their development platform, rendering previous best practices obsolete. However, just knowing the technical aspects of each platform is not a guarantee that it will succeed. It is important to also see how each is distinct and to prepare you for changes through examples and sample code.The purpose of these examples is to provide a springboard to build applications on, so there is plenty of room for extending and adapting to suit your own needs.This book is one of the first of its kind to bring together three of the most popular social programming platforms under one hood. Welcome to social programming. Who This Book Is For This book is written for beginner

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    53 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us