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

Chapter 8 web services

27 0 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 đề Web Services
Thể loại Bài viết
Định dạng
Số trang 27
Dung lượng 49,99 KB

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

Nội dung

Chapter 8 Web Services Services in PHP Web Services • Web based applications • HTTP is the interface • Data is transmitted in XML or JSON • Generally intended for machine to machine communication • Re[.]

Trang 1

Services in PHP

Trang 2

• Required for mashups (generally)

Trang 5

• 4xx = client error

– 401: unauthorized, 403: forbidden, 404: not found, 411: length required

• 5xx = server error

– 500: error, 501: not implemented, 503: Service Unavailable

Trang 6

XML

Trang 7

JSON/XML/TEXT

Trang 8

• Load up this URL in your browser (add an

address)

• You could load this with simplexml_load_file()http://maps.google.com/maps/geo?q=<<your address here>>&output=xml&sensor=false

Trang 9

• SOAP

– XML wrapper for HTTP data transfer

– Can define any method (beyond Get, Post &c) – Lots of overhead

• REST

– Lighter than SOAP

– Only supports HTTP methods

Trang 12

• Imagine the whole data structure is in XML

– (but really, we are just getting data out of any database)

• Subfolders in the URL move in the complete pretend XML model like XPATH

• Snippets of XML are returned

• Examples:

http://www.flickr.com/photos/blahblahblah/4355665120/

http://www.flickr.com/photos/96592303@N00/4387898659/sizes/l/

Trang 15

Java Script Object Notation

Trang 16

• Supported by most programming languages

• Supported by many modern web services

– Flickr, Blogger, &c

Trang 17

var mydata = {};

var mydata = new object{}

Trang 19

“type” : “scripting”}

};

Trang 20

var employers =

{colleges : [“Sage”, “HVCC”, “RPI”]};

Trang 21

– blocks of name/value pairs inside arrays

Trang 25

• Returns a json object as the first argument of

a function call

• You write a function on your page to process json data

• You request a json object and specify a

callback function name

• Service returns: callback_name(json_object)

• Once script loads, function automatically runs

Trang 26

src = http://json.site.dom?callback=go

Response would be:

go({“blah” : [“blah”, blahblah, “blahblahblah”]});

Trang 27

json_encode json_decode

Ngày đăng: 09/04/2023, 06:49

w