UFCEKG-20-2 Data, Schemas & Applications Lecture 6 The Web of Data, API’s & PHP.

Slides:



Advertisements
Similar presentations
UFCEKG-20-2 Data, Schemas & Applications Lecture 5 XML & PHP.
Advertisements

DT228/3 Web Development WWW and Client server model.
L. Grewe. YQL – what is it Yahoo! Query Language.
DT211/3 Internet Development Application Internet Development Application.
Multiple Tiers in Action
Dynamic Web Pages Bert Wachsmuth. Review  Internet, IP addresses, ports, client-server, http, smtp  HTML, XHTML, XML  Style Sheets, external, internal,
UFIEKG-20-2 / 06 / Week 131 Data, Schemas and Applications Term 2 Week 13.
ITM352 Javascript and Dynamic Web Pages: Client Side Processing.
Web Programming Language Dr. Ken Cosh Week 1 (Introduction)
Quick Tour of the Web Technologies: The BIG picture LECTURE A bird’s eye view of the different web technologies that we shall explore and study.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
WEB DESIGN SOME FOUNDATIONS. SO WHAT IS THIS INTERNET.
Web Design Basic Concepts.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
UFCEKG-20-2 Data, Schemas & Applications Lecture 4 Server Side Scripting & PHP.
ITD 3194 Web Application Development Chapter 4: Web Programming Language.
Web Application Architecture and Communication. Displaying a Web page in a Browser
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 10.
Copyright © cs-tutorial.com. Introduction to Web Development In 1990 and 1991,Tim Berners-Lee created the World Wide Web at the European Laboratory for.
Server-side Scripting Powering the webs favourite services.
Introduction to InfoSec – Recitation 7 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
XML and its applications: 4. Processing XML using PHP.
Chapter 6 The World Wide Web. Web Pages Each page is an interactive multimedia publication It can include: text, graphics, music and videos Pages are.
REST.  REST is an acronym standing for Representational State Transfer  A software architecture style for building scalable web services  Typically,
Unit 1 – Web Concepts Instructor: Brent Presley. ASSIGNMENT Read Chapter 1 Complete lab 1 – Installing Portable Apps.
NASRULLAH KHAN.  Lecturer : Nasrullah   Website :
Chapter 8 Cookies And Security JavaScript, Third Edition.
10/13/2015 ©2006 Scott Miller, University of Victoria 1 Content Serving Static vs. Dynamic Content Web Servers Server Flow Control Rev. 2.0.
Web Engineering we define Web Engineering as follows: 1) Web Engineering is the application of systematic and proven approaches (concepts, methods, techniques,
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
JavaScript – Quiz #9 Lecture Code:
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Web Design (1) Terminology. Coding ‘languages’ (1) HTML - Hypertext Markup Language - describes the content of a web page CSS - Cascading Style Sheets.
Session: 1. © Aptech Ltd. 2Introduction to the Web / Session 1  Explain the evolution of HTML  Explain the page structure used by HTML  List the drawbacks.
CSE 154 LECTURE 5: INTRO TO PHP. URLs and web servers usually when you type a URL in your browser: your computer looks up the.
Ajax. –Asynchronous JavaScript and XML –Umbrella term for technologies that often: Use client-side scripting for layout and formatting Use less than full.
1 Alternative view on Internet Computing Web 1.0 –Web 1.0 is first generation, Web Information based. Driven by Information provider. Web 2.0 Ajax enabled.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
Introduction to HTML. _______________________________________________________________________________________________________________ 2 Outline Key issues.
Introduction and Principles Web Server Scripting.
NASRULLAH KHAN.  Lecturer : Nasrullah   Website :
Fundamentals of Web DevelopmentRandy Connolly and Ricardo HoarFundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar Fundamentals of Web DevelopmentRandy.
Website Design, Development and Maintenance ONLY TAKE DOWN NOTES ON INDICATED SLIDES.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Introduction to the World Wide Web & Internet CIS 101.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Web Technology (NCS-504) Prepared By Mr. Abhishek Kesharwani Assistant Professor,UCER Naini,Allahabad.
Overview Web Technologies Computing Science Thompson Rivers University.
Web Services Essentials. What is a web service? web service: software functionality that can be invoked through the internet using common protocols like.
Web Page Design The Basics. The Web Page A document (file) created using the HTML scripting language. A document (file) created using the HTML scripting.
National College of Science & Information Technology.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Lesson 11: Web Services and API's
Web Technologies Computing Science Thompson Rivers University
Javascript and Dynamic Web Pages: Client Side Processing
Tutorial 10 Programming with JavaScript
Cosc 5/4730 REST services.
Lesson 11: Web Services & API's
Introduction to Web Database By Rimpi Suman 1 1 Unit-6.
Web Systems Development (CSC-215)
Chapter 27 WWW and HTTP.
Secure Web Programming
Lesson 11: Web Services and API's
Web Technologies Computing Science Thompson Rivers University
Client-Server Model: Requesting a Web Page
Murach's JavaScript and jQuery (3rd Ed.)
Presentation transcript:

UFCEKG-20-2 Data, Schemas & Applications Lecture 6 The Web of Data, API’s & PHP

Searching the Twitter stream Twitter advanced search Bristol tweets as Atom Tweet Steam via ATOM and XQuery Twitter to RSS

o Tree structures o Navigating trees with SImpleXML in PHP5 o Object construction and navigation in PHP5 o iteration in PHP - foreach () o PHP for transformation form one XML vocabulary to another o string building with.= assignment o recursive functions Last week:

o Most sites are built for humans to browse. HTML pages designed for humans are not good for machines o Page is a complex document including CSS, Javascript and HTML layout o Many pages are not well-formed XHTML o Hard to identify the real content of the page o Page 'scraping' - getting the content out of a page - is possible but hard o The structure of the HTML changes from time to time even if the content is the same There are applications designed to help page scrape - e.g. Dapper Dapper Human versus machine-readable sites

o Flickr site Flickr site o Lewis Hamilton in text Lewis Hamilton in text o Lewis Hamilton in tags Lewis Hamilton in tags o Advanced Search Advanced Search Flickr site

Interface designed for a programmer to use in a program o Provides a machine-readable content o Can be used client-side (e.g JSON) or server-side (eg XML, Atom, RSS) o Separates the content from the presentation o Often requires personal access key (API key) to monitor and control access o Provides a rich language to query data o With authentication, allows update to user's data Application Programmer Interface (API)

Flickr API Documentation Supports multiple protocols - we will use REST (HTTP GET) method flickr.photos-search API explorer lets you experiment with queries Response from API call URL construction Flickr API Discussion Photos can be searched on a wide range of criteria not available via the usual web search. For example, geo- coded photos can be searched by location latitude and longitude and radius of circle. Flickr API

This script provides a secondary interface to Flickr using the API. The output is suitable for including in a page using iframe Peros Bridge Peros Bridge first 2 flickrsearch.php source PHP Flickr search (1)

A generic function to call any Flickr function with an api key. Accepts a method (e.g. flickr.photos.search) and an array of parameters (name=value), calls Flickr and returns the simpleXML object. function call_flickr($method,$params){ $uri = " $method. "&api_key=". FLICKRKEY."&". join($params,"&"); $xml = get_file($uri); return new SimpleXMLElement($xml); }; The FLICKRKEY is defined in a separate file.A key is freely available on registration but there are limits on the rate and number of requests made, and keys are bound to a specific host. (i.e. they will only work with scripts running on that host.)a separate file PHP Flickr search (2)

function get_flickr_photos($flickr,$number) { $h = ""; for ($i =0; $i < $number; $i++) { $photo = $flickr->photos->photo[$i]; $pa = $photo->attributes(); $imguri = " >server}/{$pa->id}_{$pa->secret}_m.jpg"; $photouri = " >owner}/{$pa->id}"; $h.= " "; } return $h; }; o A function to construct a list of images from the response to the search. o Accepts an XML object returned from the search and constructs a string of $number img tags PHP Flickr search (3)

A function to get a URI parameter, defaulting to a value if none provided. PHP Flickr search (4) function get_uri_parameter($name,$default) { if (isset($_REQUEST[$name])) return $_REQUEST[$name]; else return $default; };

The main program The script accepts two parameters - the text to search for and the number of images required. It returns a div containing the images. <?php require ("commonlib.php") require ("flickrlib.php"); function get_uri_parameter (...)... $text = get_uri_parameter("text",""); $number = get_uri_parameter("number",10); $flickrXML = call_flickr( "flickr.photos.search", array("text=". rawurlencode($text),"sort=relevance") ); echo " ". get_flickr_photos($flickrXML,$number). " "; ?> PHP Flickr search (5)

Development Hints o Essential : Use the isa server for debugging o Change preferences in Explorer so that known filetypes are not hidden o Use Firefox for debugging and Error Console for Javascript o Insert echo statements at suitable points e.g. to show a constructed URI o Test an example of any constructed URI directly in the browser o Many errors are caused by the wrong case, missing semi- colons and quotes. o Use Google search to access documentation and advice on problems

o YouTube - search does not need an API key and results are in Atom format o Google Maps API - needs an API key o Javascript API o REST API to geocode addresses e.g. Prince Street BristolPrince Street Bristol o Static Google Maps Static Google Maps o see Dapper and Programmable Web for other APIs Other APIs

o Application Programmer Interface o API documentation o API Key o Debugging tricks Concepts