Contents
Preface Acknowledgments Chapter 1
1.1 1.2 1.3 1.4 1.5 1.6
xiii xvii
What Is zembly? 1
Social Programming 2 zembly’s Environment 4 zembly’s Audience 6 Publishing and Scaling with zembly 7 Monetizing with zembly 8 Coming to zembly Soon 8
Meebo 8 OpenSocial 8 Scripting Languages 9 A Final Thought 9
Chapter 2
2.1
zembly Basics
13
11
What You Will Learn 12 Examples in This Chapter 12
Exploring the Samples
Using Clone 15 Widget Actions 16 Tags on zembly 16 AmazonProductSearchWidget—Widget Preview Embedding AmazonProductSearchWidget 18 Sharing Your Widgets with Clearspring 19
17
v
vi
Contents
2.2
About You—Your Home Page
Your Profile 21 People—Adding Contacts 22
20
2.3 2.4
Your Keychain and Service Providers 24 Creating Your First Service: LoanPaymentService
Specifying Parameters in a Service 27 Error Handling 29 Testing LoanPaymentService 30 Capturing Example Return Data 30 Saving Drafts 31 Using the JavaScript Editor 31 Publishing LoanPaymentService 32 Calling LoanPaymentService 32
25
2.5
Creating Your First Widget: LoanPaymentWidget
Uploading an Image 36 Including Library Prototype JS 37 Building LoanPaymentWidget 38 Using CSS for Styling 38 Calling LoanPaymentService in Your Widget Previewing and Publishing 41 Embedding LoanPaymentWidget 42
34
39
2.6
Drafts, Versions, and Timelines 42
Edit History 42 Viewing Versions 44 Online/Offline Status 44
2.7
Putting It All Together—Using the WeatherBug API
Using Your Keychain 46 Building WeatherBugService 47 Using E4X and JavaScript 48 Calling WeatherBugService 50 Building WeatherBugWidget 51
45
Chapter 3
Building Flickr Widgets
55
What You Will Learn 55 Examples in This Chapter 56
Contents
vii
3.1 3.2
Using Flickr 56 Building a Slide Show Widget
57
Looking at the Source 59 Using CSS Styles 59 Working with JavaScript 61 Sharing Your Widget 66 Embedding Your Widget in a Web Page
67
3.3
Building a Service for Your Flickr Photos
Getting a Flickr Application Key 68 Creating Service FlickrPeopleService 68 Using Find & Use to Add JavaScript 69 Testing and Publishing 71
67
3.4
Creating a Flickr User Slide Show Widget 71
Specifying Widget Parameters When You Embed 72 Creating Widget MyFlickrRandomSlideshow 73 Reusing JavaScript Code 74
Chapter 4
4.1 4.2
Building Zillow Widgets
79
What You Will Learn 79 Examples in This Chapter 80
Using Zillow 80 Building a Zillow Service
82
Obtaining a Zillow API Key 82 Zillow Property IDs 82 Building a Zillow-based Service with Parameters Using E4X and JavaScript 84
83
4.3
Building a Zillow Widget 88
Creating RecentSalesWidget 89 Embedding RecentSalesWidget 92
4.4
Building a Google Maps Mashup
92
Exploring Google Maps API 93 Designing Widget RecentSalesMashup 94 Creating Widget RecentSalesMashup 95
viii
Contents
Chapter 5
Facebook Basics
101
What You Will Learn 101 Examples in This Chapter 102 The New Facebook Design 102
5.1
About Facebook 103
What Is a Facebook Application? 103 Canvas Page 104 The Facebook User 105 Friends 105 Your Profile 105 Applications and Application Settings 106 Profile Boxes 108 Left-Hand Column 109 Application Tabs 110 Application Access 111 Email and Notices 112 Story Types and News Feed Templates 112 Profile Publisher 113 Application Info Sections 114
5.2
Creating a Facebook Application 114
Facebook Application Wizard 115 Core Services and Widgets 120
5.3
Loan Calculator—Your First Facebook Application 121
Deleting Home and Creating a New Widget 121 Editing Widget Home (NewWidget) 122 Uploading Resource Image 123 Including Library Prototype JS 124 Previewing and Publishing Widget Home 124 Configuring Home 124 Running Your Application in Facebook 125 Facebook Application Defaults 126 Enhancing Your Application on Facebook 127 Making Your Application Accessible 129
5.4
zembly and Facebook—A Closer Look
Exploring the Facebook APIs 131 Facebook Code Testing Tools 133
130
Contents
ix
Application Context and Permissions 134 Controlling the Allow Access Process 136
5.5
BuddyPics—Using FBML and FBJS
137
FBML Overview 138 The BuddyPics Application 139 Adding Content to Your Profile 141 Building the BuddyPics Facebook Application 141 Creating Dynamic Content with FBML 142 BuddyPics Home Widget (FBML) 143 Service GetFriendInfo 153 Testing a Facebook Service 155 Service UpdateProfileBox 157 Summary of Differences with FBML Widgets 158 The HTML Alternative 160 What’s Next 160
Chapter 6
6.1
Facebook Integration
161
162
What You Will Learn 162 Examples in This Chapter 162
Capital Punishment—A Challenging Facebook Application
Cloning the Facebook Application 164 The Capital Punishment Home Widget 164 Service UpdateProfileBox 181 Publishing Feed Stories 182 Sending Challenge Invitations 186 Application FriendChooser 191
6.2
Using the Facebook Data Store and FQL 191
Facebook Data Store Model 192 Data Model for Capital Punishment 193 Facebook Data Store Admin Tool 193 Service CreateDataStore 196 Service SaveScore 198 Using FQL with DataStoreAdmin 199 Services FBMLGetMyScores and FBMLGetFriendScores Service DeleteScore 204 Widget SeeScores 205
201
x
Contents
6.3
Mood Pix—Leveraging Facebook Integration
Go To Application 209 About Mood Pix 209 Widget Home 214 Service FeedHandlerService 218 Application Info Section 219 Mood Pix Application Tab 223 Profile Publisher 224 Widget SendMoodPix 227 Mood Pix Widgets and Services—The Rest of the Story
208
231
6.4
Facebook Connect—Looking Forward
231
234
Running the zemblyConnectDemo Widget 232 fbConnectDemo2 and fbConnectDemo3 Widgets
Chapter 7
7.1 7.2
Working with Dapper
237
What You Will Learn 237 Examples in This Chapter 238
Getting Content with Dapper 238 Photo Search Widget 239
Creating the flickrPhotoSearch Dapp 240 Creating a Dapper-Based Service 243 Creating a Dapper-Based Widget 244
7.3
London Tube Widget 248
Creating the London Tube Dapp 250 Creating Service LondonTubeJourneyPlanner Parameter Escape Value 253 Creating LondonTubeWidget 254 252
7.4
MLB Scores Widget 258
Building the mlbupdate Dapp 259 Creating Service mlbscores 262 Creating mlbScoresWidget 263
7.5
Creating a Feed Reader 265
Building a Feed-Based Dapp 267 Building Service GambitsfromGailFeed 268 Building GambitsSummaryWidget 268
Contents
xi
Chapter 8
8.1
Widget Gallery
273
What You Will Learn 273 Examples in This Chapter 274
LiveWeatherBugWidget 274
Using E4X to Build LiveWeatherBugService Building LiveWeatherBugWidget 279 Embedding LiveWeatherBugWidget 283 276
8.2
LiveWeatherMapWidget
284
Modifying LiveWeatherBugService 285 Building LiveWeatherMapWidget 286 Embedding LiveWeatherMapWidget 289
8.3
LondonTubeMapWidget
289
Building LondonTubeMapWidget 291 Adding Geocode Data for Stations 292 Using CSS for the Map Widget 293 Building Mashup LondonTubeMapWidget 294 Embedding LondonTubeMapWidget 298
8.4
Yahoo! Pipes
298
Creating a Pipe 300 Fetch Feed Source 300 Union Operator 301 Filter Operator 302 Sort Operator 303 Saving and Publishing Your Pipe 304 Building Widget zemblyrumblings 304 Doing More with Yahoo! Pipes 307
Chapter 9
9.1
Building for the iPhone
310
311
309
What You Will Learn 309 Examples in This Chapter 310
Targeting the iPhone
iPhone Applications 311 A Closer Look at the iPhone The iUI Library 313
xii
Contents
9.2
iLoanPayment Widget
314
Running iLoanPayment on Your iPhone 315 Adding an Icon to Home Screen 317 Including the iUI and Prototype Libraries 318 Widgets on the iPhone Dashboard 318 Building the iLoanPayment Widget 319
9.3
iLiveWeather Widget
322
Building the iLiveWeather Widget 324 iLiveWeather CSS Code 325 iLiveWeather JavaScript Code 327
9.4
iCapitalPunishment Widget 331
Building the iCapitalPunishment Widget 333 iCapitalPunishment CSS Code 334 iCapitalPunishment JavaScript Code 335
9.5
Facebook Integration—iPhoneHome Widget
Executing a Facebook Application Widget Facebook Session Authorization 339 Building the iPhoneHome Widget 341 Building the iPhoneHome Services 348 339
337
9.6
iLondonTube Widget
348
351
iLondonTube Resources 350 Building the iLondonTube Widget
9.7
iCandy—Samples from Apple
iLeaves Widget 356 iButtons Widget 359
356
Index
363