OpenSocial Network Programming

Lynne Grewe


e-books shop
OpenSocial
Network Programming


About the Author
Lynne Grewe, Ph.D., is founder and director of ILab at California State University East Bay, where she as a professor in Computer Science. She created the first class in a university to teach social network programming, using the platforms of OpenSocial, Facebook, and others. Previously, she worked at IBM as a media specialist. She received her Ph.D. in Electrical and Computer Engineering from Purdue. She has collaborated with numerous companies in social networking. She has published in professional journals and presented at many conferences and symposiums. Lynne has contacts in industry that are spearheading social network platforms and including Sun, Yahoo!, and Google. She is also a leader in the
community developing personalization/socialization of the social network experience and is a member of the OpenSocial foundation.

Acknowledgments
I would like to thank a number of people for helping me create the best book possible. Thank you to Kevin Shafer, my development editor at Wiley, who with his considerable experience made this book shine. Thank you to Carol Long, executive acquisitions editor at Wiley, a great editor who guided me through the process. Also, thanks to the Wiley publishing team, including Sara Shlaer and Kirk Bateman.

A special thanks to Ken Walton, director of business development and chief software architect at Klick-Nation, who served as technical editor and spent many hours reviewing the book, making suggestions, and helping to ensure that there are no errors.

I also interviewed a number of people to create this book and want to thank the following for their invaluable assistance:
􀁔 KenWalton, director of business development and chief software architect, KlickNation
􀁔 Cody Simms, Yahoo!, senior director, Yahoo! platforms
􀁔 Prakash Narayan, Zembly
􀁔 Jia Shen, CTO and founder, RockYou
􀁔 Lan LiaBraaten, Sara Jew-lim, Jan Penner, Google
􀁔 David Young, Slide
􀁔 Paul Linder, platform architect, hi5
􀁔 Rod Boothby, vice president, Joyent
􀁔 Ali Partovi, CEO, iLike
􀁔 Vikas Gupta, cofounder/CEO, Jambool
􀁔 Charlene Li, emerging technologies and coauthor of ‘‘Groundswell’’
􀁔 Kevin Chou, CEO, Watercooler
􀁔 Rhett Mcnulty, COO, Shopit
􀁔 Stefano Pochet, Nealab Technologies, Freebar
􀁔 Jeff Roberto, Friendster
􀁔 Gina Olsen, imeem
􀁔 Pieter De Schepper, Netlog
Introduction
OpenSocial is a new and exciting platform that allows you to create and deploy social networking applications on multiple networks, including MySpace, hi5, imeem, Friendster, Netlog, orkut, and more. It is an alternative to the single-container Facebook-only API used by Facebook. This book teaches you step by step how to create viral and engaging social network applications using OpenSocial. Also discussed are front-end and back-end issues, how to make money with social network applications, and marketing strategies. This book also features new emerging technologies that let you ‘‘mash/mix’’ a social application.

Who This Book Is For
The primary target audience of this book is programmers interested in state-of-the-art social network programming with OpenSocial. While a brief introduction to JavaScript is provided, some familiarity with it and Web development is ideal. The parts of this book dealing with a discussion of social applications and emerging technologies are appropriate for the broader audience of tech-savvy social network users who want to easily make their own applications.

What This Book Covers
This book gives a programmer a well-rounded education in the creation of applications for the most popular social networks using OpenSocial. What sets this book apart from others in social network application development is that it shows you how to develop applications for more than one platform, featuring OpenSocial in a ‘‘write once, deploy to many social networks’’ fashion. In addition, the book features a discussion of how to make viral, social applications, and discusses issues surrounding both front-end and back-end needs. Finally, this book is unique in that it also includes a discussion of some emerging platforms that allow even non-programmers to create applications.
Some of the highlights of this book include the following:
􀁔 Learning the OpenSocial API
􀁔 Understanding the OpenSocial architecture, including both client (JavaScript API) and server (RESTful) APIs
􀁔 Learning how to develop OpenSocial applications (including deployment on multiple platforms)
􀁔 Learning about front-end and back-end solutions
􀁔 Discovering marketing and monetization ideas
􀁔 Learning about emerging technologies

How This Book Is Structured
Following is a breakdown of the contents of this book:
􀁔 Chapter 1: Social Network Programming — This chapter provides an overview of some of the
most popular social network platforms from a user’s perspective. Next, the chapter discusses
what a social network application is, and how applications can be found in different platforms
and controlled. This chapter also provides an overview of some of the most popular techniques
used in creating both ‘‘social’’ and ‘‘viral’’ applications. Tips and tricks from industry experts are
provided.
􀁔 Chapter 2: Introduction to OpenSocial —This chapter discusses OpenSocial as an open API
for social network development that is meant for use in multiple social network platforms. This
chapter also discusses the basic anatomy (architecture) of OpenSocial. Here, you will also learn
about OpenSocial data formats. The chapter concludes with an examination of how to deploy it
on multiple containers (social networks).
􀁔 Chapter 3: Gadget XML and Gadget API — This chapter provides an examination of the Gadget XML and Gadget API specifications.
􀁔 Chapter 4: OpenSocial API —This chapter provides an in-depth discussion of the OpenSocial
JavaScript API, with numerous code samples.
􀁔 Chapter 5: OpenSocial RESTful API —This chapter examines the new OpenSocial RESTful API, which allows server-side programs to access OpenSocial data directly.
􀁔 Chapter 6: Programming Fundamentals — This chapter examines some of the fundamental concepts you should know when working with an OpenSocial application.
􀁔 Chapter 7: Sample Applications —This chapter shows how to create applications that feature
different social hooks.
􀁔 Chapter 8: Performance, Scalability, and Monetization — This chapter discusses scalability,
and provides tips on maximizing this important characteristic of OpenSocial applications. The
discussion examines the inner components making up an application, as well as a variety of
available hosting solutions. The chapter examines how to fine-tune applications for better performance, as well as how to maximize the benefits of a scalable design. The chapter concludes
with a look at how to use your application to make money.
􀁔 Chapter 9: OpenSocial Templates, Markup, and Emerging Technologies — This chapter examines the OpenSocial Templates standard, OpenSocial proxied content, OpenSocial client libraries, and other emerging technologies.

What You Need to Use This Book
This book assumes that you are a user of social networks and have an account on one or more networks (such as MySpace or hi5). Having an understanding of JavaScript and basic Web development technologies is ideal. Finally, as described in the book, to create and deploy your own application, you will need an account on an appropriate server.


Table of Contents
Introduction xvii
Chapter 1: Social Network Programming 1
Social Network Platforms 2
MySpace 2
hi5 5
orkut 7
Friendster 8
imeem 9
Freebar 9
Netlog 11
Yahoo! 12
Other Networks 14
Social Network Applications 14
Application Discovery 15
Application Installation 16
Application Appearance 17
Control of Applications 25
Making Applications Social and Viral 29
Application Goals 29
Growth 30
Engagement 30
Good Look and Feel 32
Dynamic Evolution 32
Self Expression 32
Social Exposure 33
Relationship Building 33
Real-World Problem Solving 33
Application Trends 33
Reach (General Appeal) Applications 35
Vertical (Targeted) Applications 36
Template-Based Application Development 36
Brand Applications 39
Destination Applications 39
Longer Engagement 39
Use of Media 39
Internationalization 41
Self Expression 43
Partnering 43
Virtual Currencies, Goods, and Points 43
Mobile Applications 45
Increased Use of Social Data 45
Increased Use of Application Data 46
Viral Channels and Features 46
Social Network Identity 48
Marketing —The Next Step 50
Retention 53
Tips for Good Application Development 53
Summary 54
Chapter 2: Introduction to OpenSocial 57
OpenSocial History 57
OpenSocial Architecture 59
Client-Based API 60
Server-Based API 61
Application Architecture 65
Sample Application 66
OpenSocial Data Formats 67
JSON 67
Atom 68
XML 68
Application Deployment 69
MySpace Deployment 69
hi5 Deployment 76
orkut Deployment 77
Netlog Deployment 80
imeem Deployment 80
Friendster Deployment 82
Freebar Deployment 85
What You Need to Get Started 85
Summary 88
Chapter 3: Gadget XML and Gadget API 89
Gadget XML 89
Gadget API 97
Core Gadget API 97
Feature-Specific Gadget API 104
Multiple Views 109
Changing Views Dynamically 111
Lifecycle Support 111
Summary 112
Chapter 4: JavaScript API 113
A Simple Application in OpenSocial 113
OpenSocial API Features 117
People 118
ViewerData Example 119
GetFriends Example 121
Info Example 124
IdSpec 124
Activities 132
Messages —Email and Notifications 133
Activity Posting (Updates) 136
Invitations to Install 139
Persistence 141
Information Storage 142
Information Retrieval 142
Detail of OpenSocial JavaScript API 146
Summary 170
Chapter 5: OpenSocial RESTful API 169
Getting to Know REST 169
Purely RESTful Architecture 171
RESTful-RPC Hybrid Architecture 171
Looking at an Example of REST 171
OpenSocial RESTful Server-Side Programming 173
Completely Server-Based OpenSocial RESTful API Application 173
Hybrid OpenSocial JavaScript and RESTful API Application 175
OpenSocial RESTful Application Architecture 175
OpenSocial REST Authorization and Authentication (OAuth) 176
OAuth Steps 177
OAuth Parameters 179
OAuth Requests 179
OAuth Signing Requests 180
OAuth Tokens (the Response) 181
OAuth in PHP 181
HTTP Errors 195
OpenID 195
Key Cache and Token Management 195
OAuth Libraries 196
What You Need 196
hi5 Authentication Scheme 196
OpenSocial RESTful API Details 198
OpenSocial REST Request Construction 198
OpenSocial REST API Specification 200
Data Formatting and Atom/AtomPub 203
HTTP Method Type 210
OpenSocial REST Response 211
What You Need 212
OpenSocial REST Application Deployment 212
HTTP Status Codes 213
OpenSocial REST Support Discovery 213
OpenSocial Security with the REST API 216
OpenSocial REST API Future 216
OpenSocial RPC Protocol 216
Summary 219
Chapter 6: Programming Fundamentals 223
Application Testing 223
Front-End GUI Design Tips 224
Navigation Tabs 224
Look and Feel 226
Social Network-Specific Looks 227
External Resources 228
Caching Issues 230
POST Request 231
Signed Request 232
Performance Improvement Using Preload 234
Capabilities Inquiry 234
Action Requests and Permissions 234
Summary 235
Chapter 7: Sample Applications 235
Person/People Applications 235
Requesting a Maximum Number of Friends 236
Using Multiple Requests for Friends 236
Requesting Only Friends Who Have the Application Installed 237
Producing a Paginated Friends List 238
Using Pronouns 239
Creating a Friend Selector 241
Testing If Two Users Are Friends 243
Finding Top Friends Who Have the Application Installed 244
Friends of Friends 246
Communications Applications 246
Making Signed Requests 247
Creating Minimessages 249
Creating Gadget Message Bundles 250
Using Message and Activity Templates 251
Using Message Summaries 254
Using Media Items in Activities 254
Clearing AppData 258
Understanding Environment—Support and Domain 259
Handling Errors 262
Container Compliance and NOT_IMPLEMENTED 262
Checking and Asking for Permissions 263
Working with Container-Specific Extensions 264
hi5 Lifecycle Extension 265
DataRequest Extension 266
Fields Extension 266
hi5 Template Library 266
Using Internationalization, Localization, and Globalization 267
Using Flash Media 271
Option 1: Using the Gadget API 271
Option 2: Using the SWFObject JavaScript Library 272
More Configuration Options 273
Container Support 274
JavaScript Tools for Applications 274
Summary 275
Chapter 8: Performance, Scalability, and Monetization 279
Understanding Scalability and Performance 280
Defining Scalability 280
Using Scalability Metrics 281
Performance Problem Areas 282
Scaling Up or Out 282
Understanding Architecture 282
Understanding Subsystems 284
Web Server 285
Application Server 285
Load Balancing 286
Caching 286
Content Delivery Networks (CDNs) 292
Understanding Hosting Solutions 292
What They’re Saying about Hosting Solutions 294
Amazon Web Services (AWS) 294
Joyent 300
Other Hosting Solutions 301
Case Studies 301
Understanding Database Issues 302
Distributed Systems (Scale Out) 303
Database Sharding 303
Understanding Redundancy 304
UsingMonitoring 304
Understanding Software Design 305
Language Choice 307
Versioning 307
OpenSocial Performance Tuning 308
Minimizing the Number of HTTP Requests 308
Batching Multiple Requests 308
Using OpenSocial AppData as a Container Cache 309
Reducing the Number of DNS Lookups 309
Reducing the Number of Files 309
Turning on the Persistence Feature in a Web Server 309
Compressing Content Using GZIP 310
‘‘Minifying” JavaScript 310
Using CSS in a Header 310
Locating JavaScript at the Bottom 311
Caching versus Requests for External Files (JavaScript, CSS) 311
Flushing a Server Response 311
Monitoring Client Code Performance 311
Preloading OpenSocial Content 313
Achieving Good Load Times 314
Using OpenSocial get from Cache 314
Using CSS Image Sprites 314
Using Analytics 314
Google Analytics 315
Yahoo! Web Analytics 317
Sometrics 318
Social Network-Provided 318
Using Scalable User Interface Design 318
Making theMost of User/System Support 319
Monetization 320
Advertising 320
Affiliate Programs 321
Partnering 322
Virtual Goods and Virtual Currency 322
Real Goods and Micropayments/Micro-Transactions 323
Monetization Case Studies 323
Summary 325
Chapter 9: OpenSocial Templates, Markup, and Emerging Technologies 325
OpenSocial Templates Standard 325
Requiring a Feature 326
Understanding Basic Template Construction and Use 327
Naming Templates 328
Using Expressions in Templates 329
Using Variables and Passing Data to a Template 330
Calling Templates with Parameters 331
Using the repeat Attribute for Looping 332
Using Conditional Tests 332
Localization with Templates 332
Using a Separate Definition File for Templates 333
OpenSocial Markup Language 334
OpenSocial Data Pipelining 345
OpenSocial Template Examples 350
OpenSocial Proxied Content 352
OpenSocial Client Libraries 353
Yahoo! Open Strategy 353
Y!OS Architecture 354
Yahoo! User Profiles 355
Yahoo! User Updates 355
Yahoo! Applications (YAP) 356
YAP Application Development Steps 360
YAP OpenSocial Application Development 361
Yahoo! Query Language 364
Understanding the Yahoo! User Interface (YUI) 365
Using Yahoo! Markup Language (YML) 365
Y!OS Application Examples 366
iWidgets 367
Zembly 368
Understanding the Zembly Application Structure 369
Understanding a Zembly Service 370
Understanding a Zembly Widget 371
Understanding a Zembly Snippet 371
Understanding a Zembly Key Chain 371
Creating an OpenSocial Application in Zembly 371
Publishing an Application 373
Creating Your Own Service 373
Summary 374
Index 375


Screenshot

e-books shop

Purchase Now !
Just with Paypal



Product details
 Price
 Pages
 412 p
 File Size
 6,106 KB
 File Type
 PDF format
 ISBN
 978-0-470-44222-7
 Copyright
 2009 by Wiley Publishing, Inc 
  ●▬▬▬▬▬❂❂❂▬▬▬▬▬●
●▬▬❂❂▬▬●
●▬❂▬●

═════ ═════

Loading...
DMCA.com Protection Status