TAILIEUCHUNG - Developing Large Web Applications- P16

Developing Large Web Applications- P16:This book presents a number of techniques for applying established practices of good software engineering to web development—that is, development primarily using the disparate technologies of HTML, CSS, JavaScript, and server-side scripting languages. Whereas there are many books on how to use languages, how to use libraries, and how to approach software engineering, this is the first book to codify many of the techniques it presents. These techniques will make the components of your own web applications more reusable, maintainable, and reliable | Data from Web Services A web service is a system that defines an API for accessing information over a network. Data often is returned as XML but JSON see Data in the JSON Format on page 132 is very popular as well. The simple interface natural abstraction and ubiquity of web services makes them very desirable for interfacing with backend systems. To access a web service from a data manager you can use the PHP Client URL cURL library. This library provides a simple way to communicate with many different servers using various protocols. Example 6-13 provides a basic example of a data manager to access a web service using cURL. Example 6-13. Using cURL inside of a data manager to access a web service class NewCarListingsDataManager public function __construct parent __construct public function get_data load_args load_data load_stat ch curl_init Set the URL to the web service required by the data manager. url . curl_setopt ch CURLOPT_URL url curl_setopt ch CURLOPT_HEADER false curl_setopt ch CURLOPT_RETURNTRANSFER true header Content-Type application xml results curl_exec ch curl_close ch Do whatever processing is needed to the data that was returned. . Because web services involve establishing connections over a network they can take time to generate a response. To address this it s a good idea to run multiple data managers for web services in parallel. You can do this using the cURL functions for making parallel requests . curl_multi_init curl_multi_add_handle curl_multi_exec etc. . Data from Web Services 131 Data in the JSON Format When we explore large-scale Ajax in Chapter 8 you ll see that often it s useful to exchange data between the server and browser using JSON. This is because JSON is just the normal JavaScript syntax for object literals. Once you evaluate the data in the browser using eval or more safely json_parse downloadable from http json you can use the data like any other JavaScript object. It s also very lightweight. Considering

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.