1. Trang chủ
  2. » Công Nghệ Thông Tin

How to Do Everything with Web 2.0 Mashups phần 1 pptx

33 340 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề How to Do Everything with Web 2.0 Mashups
Tác giả Jesse Feiler
Trường học McGraw-Hill Companies
Chuyên ngành Web Development
Thể loại Sách giáo trình
Năm xuất bản 2008
Thành phố New York
Định dạng
Số trang 33
Dung lượng 1,67 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com... How to Do Everything with Web 2.0 Mashups New York Chicago San Francisco Lisbon London Madrid Mexico City Mila

Trang 1

Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com

Trang 2

How to Do Everything with

Web 2.0 Mashups

New York Chicago San Francisco Lisbon London Madrid Mexico City Milan New Delhi

Jesse Feiler Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com

Trang 3

Copyright © 2008 by The McGraw-Hill Companies All rights reserved Manufactured in the United States of America Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher

0-07-159568-6

The material in this eBook also appears in the print version of this title: 0-07-149627-0.

All trademarks are trademarks of their respective owners Rather than put a trademark symbol after every occurrence of a trademarked name,

we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark Where such designations appear in this book, they have been printed with initial caps

McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales promotions, or for use in corporate training programs For more information, please contact George Hoare, Special Sales, at george_hoare@mcgraw-hill.com or (212) 904-4069

TERMS OF USE

This is a copyrighted work and The McGraw-Hill Companies, Inc (“McGraw-Hill”) and its licensors reserve all rights in and to the work Use

of this work is subject to these terms Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hill’s prior consent You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohibited Your right to use the work may be terminated if you fail to comply with these terms

THE WORK IS PROVIDED “AS IS.” McGRAW-HILL AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE McGraw-Hill and its licensors do not warrant

or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error free Neither McGraw-Hill nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting therefrom McGraw-Hill has no responsibility for the content of any information accessed through the work Under no circumstances shall McGraw-Hill and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the possibility of such damages This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or otherwise

DOI: 10.1036/0071496270

Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com

Trang 4

We hope you enjoy this McGraw-Hill eBook! If you’d like more information about this book, its author, or related books and websites, please click here.

Professional

Want to learn more?

Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com

Trang 5

For Anne Kaufman

Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com

Trang 6

About the Authors

Jesse Feiler has written a number of books about FileMaker, Mac OS X, the Web, and new

technologies; his books have been translated into Japanese, Chinese, Polish, German, Spanish,

French, and other languages His most recent book is Special Edition Using FileMaker 9 As

director of North Country Consulting, he has designed and implemented a variety of solutions for small businesses and nonprofits in fields such as production, marketing, the arts, printing and publishing, food service, and construction He has taught and consulted widely on nonprofit governance, and he is the founder of ChamplainArts.com—a listing of cultural events in 2 states,

2 countries, and 2 languages

About the Technical Editor

Jim Bumgardner is a senior technical guru at Yahoo! Music, a teacher at Pasadena’s Art Center

College of Design, and the creative mind behind CoverPop.com and CrazyDad.com An expert

in graphics and music software, Jim makes mashups, software toys, and experimental user interfaces using Flash, JavaScript, PHP, and other tools

Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com

Trang 7

Contents at a Glance

PART I Introducing Mashups

1 Welcome to the World of Mashups 3

2 Understanding the Mashup World 15

PART II Learn Mashup Technologies 3 Know the Web 2.0 Mashup Rules and Design Principles 25

4 Use XML to Structure Data 35

5 Use JavaScript to Script the Mashup Page 47

6 Use PHP to Perform Server-Side Scripting 61

7 Use MySQL with PHP to Retrieve Mashup Data 79

8 Use RSS and Atom to Receive Data Automatically 97

9 Use XMLHttpRequest, XML-RPC, REST, and JSON to Retrieve Data 113

10 Use XHTML to Structure the Mashup Pages 127

PART III Build Your Own Mashups 11 Implement a Basic Mashup 143

12 Use the Google Maps API 163

13 Build Mashups with the Google Maps API 179

14 Use the Amazon Web Services and Google Search APIs 205

15 Build a Mashup to Search Amazon and Google at the Same Time 225

16 Use the Flickr API 241

17 Build a Mashup to Search Flickr and Google at the Same Time 255

18 Use the eBay API 265

19 Map the Locations of eBay Items 279

Index 291

Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com

Trang 8

This page intentionally left blank

Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com

Trang 9

Acknowledgments xv

Introduction xvii

PART I Introducing Mashups CHAPTER 1 Welcome to the World of Mashups 3

Sell Things with Mashups 5

Provide Information with Mashups 8

Create Art with Mashups 11

CHAPTER 2 Understanding the Mashup World 15

Describe a Mashup 16

Use Multisource Mashups 16

Use Presentation Mashups 17

Build Your Own Mashup 17

Decide on Your Mashup’s Objective 18

Identify the Data and the Keys 18

Get Access to the Data 18

Regroup 19

Design the User Interaction 19

Implement the Mashup 19

Implement the Starting Page 20

Make Money with Mashups 20

Achieve Goals with Mashups 20

Improve Productivity with Mashups 21

Know How to Use Mashup Data Legally 21

PART II Learn Mashup Technologies CHAPTER 3 Know the Web 2.0 Mashup Rules and Design Principles 25

Manage Multiple Technologies for Mashups 26

Separate Data from Presentation 27

Contents

vii

For more information about this title, click here Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com

Trang 10

viii How to Do Everything with Web 2.0 Mashups

Use Scripts 29

Server-Side Scripting 30

Browser-Side Scripting 30

Access Data with APIs 30

Minimize Full-Page Loading 31

Make Your Mashup Visible to Search Engines 32

Use Object-Oriented Programming Techniques 33

Adopt Standards 33

CHAPTER 4 Use XML to Structure Data 35

Understand XML Structure and Purpose 36

Learn Basic XML Syntax 38

Create and Use XML Elements 43

Use Attributes to Identify Data Characteristics 44

Avoid Confusion by Using Namespaces 45

CHAPTER 5 Use JavaScript to Script the Mashup Page 47

Understand JavaScript Structure 49

Place JavaScript Scripts in Script Elements 49

Use Scripts from an External Source with the src Attribute 49

Scripts Are Interpreted as They Are Encountered on the HTML Page Unless They Are in the Head Element 50

You Can Use Semicolons to End Statements 50

Continue Quoted Text Strings with \ and Concatenation (+) 50

Use Spaces and Comments for Readability 51

JavaScript Is Case-Sensitive 51

Use Local and Global Variables 51

Create and Use Functions 52

Use JavaScript Objects 54

Work with Events 55

Handle Errors 55

Handle JavaScript Environmental Problems 57

CHAPTER 6 Use PHP to Perform Server-Side Scripting 61

Understand PHP Structure 62

Use PHP Delimiters 64

Use Comments 65

Terminate PHP Statements 65

Start a PHP Script by Submitting an HTML Form 65

Use PHP Variables and Arrays 69

Use PHP Strings 69

Differentiating Between Single and Double Quotes 69

Using Heredoc 70

Building Concatenated Strings 71

Control PHP Operations 72

Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com

Trang 11

Contents ix

Build a Web Page with PHP 72

The HTML Source Code to Be Built 72

The PHP Code to Build the HTML Source Code 73

Structure Multiple PHP Files 76

CHAPTER 7 Use MySQL with PHP to Retrieve Mashup Data 79

Understand SQL and Databases 80

Create SQL Queries 82

Use the FEC Database 84

Use MySQL 86

Use PHP to Get to an SQL Database 87

Connect to the Database 87

Create and Process the Query 88

Fetch the Data 89

Disconnect from the Database 90

Create and Load a Test Database 90

Create a Test Database 90

Load the Test Database 91

Delete Data from the Test Database 95

CHAPTER 8 Use RSS and Atom to Receive Data Automatically 97

Understand Syndication, RSS, and Atom 99

RSS 99

Atom 101

Categorize and Label a Feed 102

Parse a Feed with PHP 103

Inside the Feed’s XML Document 104

Implement the Form to Launch the Script 110

Implement the PHP Script to Parse the Feed 111

Create a Search Feed 111

CHAPTER 9 Use XMLHttpRequest, XML-RPC, REST, and JSON to Retrieve Data 113

Understand Web Services 115

Deal with Cross-Domain Scripting Issues 115

Use XMLHttpRequest 116

Constructing and Sending an XMLHttpRequest 117

Handling an XMLHttpRequest Response 118

Putting It Together 119

Implement an XML-RPC Retrieval 123

Implement a REST Retrieval 124

Implement a JSON Retrieval 126

CHAPTER 10 Use XHTML to Structure the Mashup Pages 127

Understand the Need for XHTML 128

HTML’s Ease of Use Is a Two-Edged Sword 129

Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com

Trang 12

x How to Do Everything with Web 2.0 Mashups

The XHTML Solution 129

Why This Matters for Mashups 130

What Makes XHTML Code Tricky for Mashup Results Pages? 131

The Sample XHTML Code 131

Use XHTML Structures 132

The XML Declaration 132

The Document Type Declaration (DTD) 133

The HTML Element 134

Use XHTML Syntax 134

XHTML Documents Can (and Should) Contain Comments 134

XHTML Element Syntax 134

XHTML Attribute Syntax 135

Documents Should Be Well-Formed and Valid 136

Validate XHTML 136

PART III Build Your Own Mashups CHAPTER 11 Implement a Basic Mashup 143

Decide on Your Mashup’s Objective 144

Identify the Data and the Keys 145

The Population Data 145

The Labor Force Data 148

Get Access to the Data 150

Load Labor Force Data into MySQL 152

Load Population Data into MySQL 155

Test 157

Regroup 158

Design the User Interface 158

Implement the Mashup 158

Implement the Starting Page 162

CHAPTER 12 Use the Google Maps API 163

Get Access to the Google Maps API 164

Create the Basic Mapping Page 167

Create a Map 169

Identify a Location with a GLatLng 170

Use a Geocoder 170

Create a Marker 172

Add Text to a Marker 173

Putting It Together in the Callback Function 173

Wrap It Up in PHP 174

CHAPTER 13 Build Mashups with the Google Maps API 179

Identify the Data and the Keys 180

Get Access to the Data 182

Implement the Mashup 183

Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com

Trang 13

Contents xi

Create a Campaign Contributions Mashups 192

Decide on Your Mashup’s Objective 192

Identify the Data and the Keys 193

Get Access to the Data 194

Regroup 199

Design the User Interface 199

Implement the Mashup 200

Implement the Starting Page 203

CHAPTER 14 Use the Amazon Web Services and Google Search APIs 205

Get Access to the Amazon API 206

Setting Up an Amazon Account 207

Setting Up an Amazon Associate Account 207

Setting Up an Amazon Web Services Account 209

Search Amazon for an Item 211

Required Parameters 212

General Parameters 213

Specific Parameters for ItemSearch 214

Put It Together: An Amazon Search REST Query 214

Build an Amazon Link 214

Build an Amazon Shopping Cart 216

Use the Google Search API 218

CHAPTER 15 Build a Mashup to Search Amazon and Google at the Same Time 225

Decide on Your Mashup’s Objective 226

Identify the Data and the Keys 227

Get Access to the Data 228

Design the User Interface 228

Implement the Mashup 228

The Basic Mashup Architecture 228

Code the Mashup 230

Implement the Starting Page 235

Add Debugging and Error-Checking Code 236

Debugging Code 236

Debugging the XML from Amazon 237

Checking the Result 238

Testing Error-Checking Code 239

CHAPTER 16 Use the Flickr API 241

Get Access to the Flickr API 242

Getting a Key 243

Exploring the API 244

Search for Photos 246

Use API Explorer 246

Display a Photo 250

Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com

Trang 14

xii How to Do Everything with Web 2.0 Mashups

CHAPTER 17 Build a Mashup to Search Flickr and Google at the Same Time 255

Decide on Your Mashup’s Objective 256

Identify the Data and the Keys 256

Get Access to the Data 257

Design the User Interface 258

Implement the Mashup 258

Implement the Starting Page 262

CHAPTER 18 Use the eBay API 265

Get Access to the eBay API 266

Use the API Test Tool 267

Generating the Token 268

Making the API Call 269

Use the REST Interface for GetSearchResults 271

Define Your Token and User ID 272

Set Up Variables 273

Create the Request 273

Execute the Request 273

Use the SOAP Interface for GetSearchResults 274

Define Your Token and User ID 274

Set Up Variables 274

Create the Request 274

Execute the Request 276

Parse the XML Results 277

CHAPTER 19 Map the Locations of eBay Items 279

Decide on Your Mashup’s Objective 280

Identify the Data and the Keys 280

Get Access to the Data 280

Design the User Interface 281

Implement the Mashup 282

Implement the Page Top Include 282

Implement the PHP Code 283

Implement the Starting Page 288

What’s Next? 288

Index 291

Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com

Trang 15

Roger Stewart and Carly Stapleton at McGraw-Hill worked tirelessly to help move this book along Carole McClendon, at Waterside Productions as always contributed her skills and expertise

Jim Bumgardner’s technical edits were invaluable; you will notice several code snippets and

specific suggestions from Jim that I’m happy to be able to pass along

Acknowledgments

xiii

Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com

Trang 16

This page intentionally left blank

Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com

Ngày đăng: 12/08/2014, 15:21

TỪ KHÓA LIÊN QUAN