CONTACTING OTHER SERVERS.

Slides:



Advertisements
Similar presentations
JavaScript and AJAX Jonathan Foss University of Warwick
Advertisements

1.  Understanding about How to Working with Server Side Scripting using PHP Framework (CodeIgniter) 2.
Getting Started. Edline Web Site Requirements Provide Students and Parents With: 1.A Brief Course Description 2.Your Address 3.Course Syllabus 4.Major.
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
PHP Scripts HTML Forms Two-tier Software Architecture PHP Tools.
CHAPTER 26 CREATING LOCATION-AWARE WEBPAGES USING GEOLOCATION.
August 15 click! 1 Basics Kitsap Regional Library.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
Uploading Files. Why? By giving a user the option to upload a file you are creating an interactive page You can enable users have a greater web experience.
Forms, Validation Week 7 INFM 603. Announcements Try placing today’s example in htdocs (XAMPP). This will allow you to execute examples that rely on PHP.
CSCI 323 – Web Development Chapter 1 - Setting the Scene We’re going to move through the first few chapters pretty quick since they are a review for most.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
XP Tutorial 6New Perspectives on HTML and XHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
Lecture 6 – Form processing (Part 1) SFDV3011 – Advanced Web Development 1.
Internet Applications Spring Review Last week –MySQL –Questions?
Department of Information Technology e-Michigan Web Development 0 HTML Form Creation in the Vignette Content Management Application.
Lecture 7 – Form processing (Part 2) SFDV3011 – Advanced Web Development 1.
JavaScript & jQuery the missing manual Chapter 11
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
Project Four Forms Discuss form processing Describe the difference between client-side and server-side form processing Add a horizontal rule to a Web page.
Set 11: Mashups (emphasis on Google tools) IT452 Advanced Web and Internet Systems.
Google Maps API. Static Maps send an HTTP GET request receive an image (PNG, GIF, JPEG) no javascript needed encode params in URL example:
XP New Perspectives on Browser and Basics Tutorial 1 1 Browser and Basics Tutorial 1.
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
Creating a Web Site to Gather Data and Conduct Research.
Python CGI programming
A little PHP. Enter the simple HTML code seen below.
06/10/2015AJAX 1. 2 Introduction All material from AJAX – what is it? Traditional web pages and operation Examples of AJAX use Creating.
Accessing MySQL with PHP IDIA 618 Fall 2014 Bridget M. Blodgett.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
School of Computing and Information Systems CS 371 Web Application Programming PHP – Forms, Cookies, Sessions and Database.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Chapter 6: Authentications. Training Course, CS, NCTU 2 Overview  Getting Username and Password  Verifying Username and Password  Keeping The Verification.
Website Development with PHP and MySQL Saving Data.
1 Chapter 9 – Cookies, Sessions, FTP, and More spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
CIS166AE : PHP Web Scripting Rob Loy. Tonight’s Agenda Housekeeping items Housekeeping items PHP basics PHP basics Student connection to server Student.
Topics Sending an Multipart message Storing images Getting confirmation Session tracking using PHP Graphics Input Validators Cookies.
ITM © Port, Kazman1 ITM 352 More on Forms Processing.
Chapter 29 World Wide Web & Browsing World Wide Web (WWW) is a distributed hypermedia (hypertext & graphics) on-line repository of information that users.
2007cs Servers on the Web. The World-Wide Web 2007 cs CSS JS HTML Server Browser JS CSS HTML Transfer of resources using HTTP.
Implementing and Using the SIRWEB Interface Setup of the CGI script and web procfile Connecting to your database using HTML Retrieving data using the CGI.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
Creating Databases for Web applications Server side vs client side PHP basics Homework: Get your own versions of sending working: both html and Flash!
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
1 HTML forms (cont.)
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
CHAPTER 8 PHP Advanced อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
HTML Links HTML uses a hyperlink to another document on the Web.
Since you’ll need a place for the user to enter a search query. Every form must have these basic components: – The submission type defined with the method.
 A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests.
1 AOL PICTURE FINDER Click FILE, Open My Picture Finder  Pictures on My Computer  My Pictures on AOL  Pictures I’ve Received Send via Order Prints.
Sessions and cookies (part 2) MIS 3501, Fall 2015 Brad N Greenwood, PhD Department of MIS Fox School of Business Temple University 11/19/2015.
: Information Retrieval อาจารย์ ธีภากรณ์ นฤมาณนลิณี
Lesson 5 Introduction to HTML Forms. Lesson 5 Forms A form is an area that can contain form elements. Form elements are elements that allow the user to.
Windows Vista Configuration MCTS : Internet Explorer 7.0.
CACHING TO IMPROVE PERFORMANCE
1 Week 8 Final Project Planning & Chapter 6 JavaScript Advanced Web Development IT225 Spring Term 2016 Marymount University School of Business Administration.
A little PHP. Enter the simple HTML code seen below.
Advanced HTML Tags:.
Access Problems and Solutions for Full-text Articles or E-books
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
AJAX.
Why is it important? ❏ Most website owners do not think that if they paste address on page or post than they have too much risk of spam. ❏
Web Browser server client 3-Tier Architecture Apache web server PHP
Web Systems Development (CSC-215)
Access Problems and Solutions for Full-text Articles or E-books
Advanced Concepts and AJAX
Presentation transcript:

CONTACTING OTHER SERVERS

Activity #1 Practice what we covered last week. 1.Gather with your team 2.Use one team member's laptop; others look on 3.Create a MySQL database 4.Create a table 5.Insert some rows into the table 6.Output the rows to a browser

Overview of contacting other servers Sometimes your web server needs some help – Sending an – Sending a text message – Retrieving data XML files, JSON, even HTML Often, this can be accomplished using a server-to-server connection

Example of server-to-server connection Browser Server Remote server Click link or type input, etc Send params Compute Send/receive data from another server Send back page

Example: Sending an <?php $to = $subj = "you are a cool dude"; $body = "I sure like reading your blog.\r\n\r\nSigned, your bud"; $hdr = "From: php"; if (mail($to, $subj, $body, $hdr)) echo("It is a good day"); else echo("It is a sad day"); ?>

Security warning Note: Spammers will use your web form to send spam, unless if a)you hardcode the "to" address as in this example b)you hardcode the body as in this example c)OR you protect the form behind login or other authentication. Also, this example should be checking for a POST. Don't send an on a GET as above.

Example: Sending a text message Sending a text message is as simple as sending a 140-character . The recipient's username is the recipient's phone # Example: would be a Verizon user Sadly, you need to know the recipient's carrier (see inset box above) to figure out the domain You need to use a different domain depending on which Short Messaging Service (SMS) carrier the recipient has: Verizon - vtext.com T-Mobile - tmomail.net AT&T - mobile.att.net Sprint - messaging.sprintpcs.com

Example: Doing a GET to a server <?php $html = file_get_contents(" echo htmlspecialchars($html); ?> /* This is VERY handy for working around the single origin policy of JS, since PHP can access any server (unless your own server admin configures your own server to prevent contacting other servers) */ /* If your URL parameter values contain non-alphanumeric characters, encode them with urlencode() */

Example: Doing a POST to a server <?php $data = array('q' => 'test'); // you could have additional parameters $ctxinfo = array('http' => array( 'method' => 'POST', 'content' => $data )); $streamContext = stream_context_create($ctxinfo); $file = fopen(" 'rb', false, $streamContext); if (!$file) echo "Error on open"; $html if (!$html) echo "Error on read"; echo htmlspecialchars($html); ?> /* This example will URL encode your POST parameters for you. */

Example: Retrieving an RSS feed <?php $url = " $xml = simplexml_load_file($url); // note: doesn't work with https due to our own server's configuration $title = $xml->channel[0]->title; $items = $xml->channel[0]->item; $nitems = count($items); echo " "; for ($i = 0; $i < $nitems; $i++) { $title = $items[$i]->title; $link = $items[$i]->link; echo " <a href='". htmlspecialchars($link); echo "'>". htmlspecialchars($title). " "; } echo " "; // var_dump($xml); ?> /* simplexml_load_file returns an object. Object properties are dereferenced with the -> syntax. */

Server-to-server vs AJAX vs tag Server-to-server – Your PHP initiates a connection to remote server – Any remote server can be contacted AJAX (covered later in this course) – Your JS initiates a connection to YOUR server – Only servers in your own (sub-)domain can be contacted ("single origin policy") – The remote JS becomes part of your page – The remote server has to provide the JS

When to use… Server-to-server – When you need to contact a server on another domain, and the other server does not provide a JS file you can include with – When you need to contact a server on another domain, and the other server does provide a JS file that you can include with AJAX – All other situations

Example: Showing a Google map No need for server-to-server connection! function init() { var geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'address': "Portland, OR"}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { var latlng = results[0].geometry.location; var config = { zoom: 8, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("mapdiv"), config); new google.maps.Marker({map: map, position: latlng}); } else { alert("Error occurred: " + status); } }); }

Example: Showing Facebook posts No need for server-to-server connection! <iframe src=" p?href=http%3A%2F%2Fwww.facebook.com%2F%3 Fref%3Dhome%5C%23%21%2F RickAstley &width =500&colorscheme=light&connections=1 0&stream=true&header=false&heig ht=400" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:400px;" allowTransparency="true">

Summary: Contacting other servers When you need data from a server – If it's your own server, AJAX is great – Else if the server offers JS you can use in Then go for it – Else Fall back on server-to-server connection