1 Why bother? Google APIs - - PDF document

1
SMART_READER_LITE
LIVE PREVIEW

1 Why bother? Google APIs - - PDF document

Administrivia !""#


slide-1
SLIDE 1

1

  • Administrivia

!""#

$%$&#' ()*$+

,%

!)"&#-'

  • .

Today

" ("$"$

  • Web services

%"//"/!$$#

  • (01!$$$

2""

(3(/!" $3,& 4$5!$

"!!$/#

!/!$

%%(#

Web service APIs

%//#"

0$3,,(

4"0#!$"!$ //"$ 6 ##!$

7"000#

!!3,,(8

2"!!*(3(595:+ 72"!!*:$:;$<#+ 0/##9!

slide-2
SLIDE 2

2

Why bother?

#0"/

###$# 0= !"# !$"" /0

$"/#

##$## "

Google APIs

#%(

%!$!/

;$#"0## !!

%(/80

&!%(

3,&"/

!

7"##

>#!>

Unthirsty

#!.??:#0:?" :!#!=%""@A7B

Yahoo! Web services

,//

("2"//

,#

#"

#!!$

#$!"

;" %(

("""$""/4

""

Geocoder API

68""$"/

""

68#$#3,,(80

#!.??!::0#:?&!

?C-?$"=!!"@#D @-BBD0@0D @7%

6!E&

Geocoder API response

F6 .#@>.0#.! #!.??!::0#:?&!?C-?;"6!: ">G F6!@>"">$@>,# "/"5###.-%5 05HIH>G F"G:-'IF?"G F$"G2-:IJF?$"G F%""G-6,%C<F?%""G F70G4C%<F?70G F?G FK!GHIH2--HF?K!G F70G4F?70G F?6G F?6G

slide-3
SLIDE 3

3

Other web services

%L./5#

!$

M0./

  • .6!#00"

Web services in PHP

("$ 7$

Web service standards

%/"" /

!"$E&2"

%(.E&2"//

"$/ #

E&26(7./%(5

)2"

SOAP

<wsdl:portType name="HelloWorld"> <wsdl:operation name="sayHello"> <wsdl:input message="impl:sayHelloRequest" name="sayHelloRequest"/> <wsdl:output message="impl:sayHelloResponse" name="sayHelloResponse"/> </wsdl:operation> </wsdl:portType> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <ns1:getPrice xmlns:ns1="urn:xmethods-BNPriceCheck" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <isbn xsi:type="xsd:string">0385503954</isbn> </ns1:getPrice> </SOAP-ENV:Body> </SOAP-ENV:Envelope> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <SOAP-ENV:Body> <ns1:getPriceResponse xmlns:ns1="urn:xmethods-BNPriceCheck" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <return xsi:type="xsd:float">14.65</return> </ns1:getPriceResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

Another Way … REST

$##! E&/

"0##"/$

.3,,(;<,"(,

%"$."$$#! E& "$.7#/5

>">

6<,*6<! ,/+

3,,(8"! ?E&/

  • 3,,(8/

6!! !E&

Religious Warfare

%(

68

/!#

  • E&8"

!

!"

#E& 0 /#

  • 46

("7 *6(7+3,,(

E&2!!"6(7

"//N//O

6<,

446

)

(#"

;<, !

42

*;<,5(,5 (4,5<<,<+

4!3,,( 7

"0# / /

slide-4
SLIDE 4

4

Different Designs

%(

6(7!!##"

exAppObj = new ExApp("example.com:1234") exAppObj.getUser() 6<,

  • 6"/"46P

http://example.com/users/ http://example.com/users/{user} http://example.com/findUserForm http://example.com/locations/ http://example.com/locations/{location} http://example.com/findLocationForm

  • userResource = new

Resource("http://example.com/users/001") userResource.delete()

Benefits of SOAP

7"/! "

#

#8

!;<,(,

Creating RESTful web services in PHP

"

&C77

6!/8 6!

< !."",:!#!

(. " 6.#!

addTwo.php

F=!#! Q@QR6<S4<,T>>UV Q@QR6<S4<,T>>UV #QBQV =G

Consuming web services

(3( 4/R$R /

46"

7"!L"

/

0 .Q!@/R$R*Q+

4;<,8 (,!#""

PHP client using addTwo

F=!#! ??"", "" Q/( @-V Q"( @2V Q @ >#!.?? :#:#$:"?W?"",:! #!>V Q :@>=@Q/(>V Q :@>D@Q"(>V Q@/R$R*Q+V =G F#GF#"GFGF?GF?#"G F"0G F!GF=!#! #Q/(V=G!F=!#! # Q"(V=G8F=!#! #QV=GF?!G F?"0GF?#G

slide-5
SLIDE 5

5

Choosing an output format

(

+ !5$"/$ X 710#")5"//

""

!E&/

+ ""//!$" X 7!!$

3,&

+ 7""0!$ X M"!""!

Using XML in web services

#$#)5

"!) E&

""L"/5"

0#

32"

"5#"

!)E&

)E& 7")$!E&

XML serialization

F=!#! 6!Y Q/V Q"V Q!V QV ?? /6!*Q/5Q5Q5Q+Y Q#2G/@Q/V Q#2G"@QV Q#2G!@QV Q#2G@QV Z Z =G

Response toXML() method

/E&*+Y Q!@>F!G>V Q!:@>F/GQ#2G/F?/G>V Q!:@>F"GQ#2G"F?"G>V Q!:@>F!GQ#2G!F?!G>V Q!:@>FGQ#2GF?G>V Q!:@>F?!G>V Q!V Z

Producing XML web services

F=!#! "*>6!:!#!>+V Q@QR6<S4<,T>>UV Q@QR6<S4<,T>>UV Q@6!*Q5Q5>!>5QBQ+V #Q2GE&*+V =G

F!G F/GF?/G F"G-F?"G F!G!F?!G FG-IF?G F?!G

Consuming XML web services

F=!#! ??E&"" Q/( @-V Q"( @2V Q @

>#!.?? :#:#$:"?W?"",E&:!#! >V

Q :@>=@Q/(>V Q :@>D@Q"(>V Q @/R$R*Q+V ??0 E&!) Q!@!E&<*Q +V #>,#>:Q!2GV =G