Pro PHP- Patterns, Frameworks, Testing and More

(vip2019) #1
CHAPTER 20 ■ ADVANCED WEB SERVICES^305

array(2) {
[0]=>
object(CallDetailRecord)#2 (4) {
["StartTime"]=>
string(23) "20070510T21:48:00-07:00"
["Duration"]=>
int(3600)
["Caller"]=>
string(12) "123-123-1234"
["Callee"]=>
string(12) "123-123-1235"
}
[1]=>
object(CallDetailRecord)#3 (4) {
["StartTime"]=>
string(23) "20070510T22:58:00-07:00"
["Duration"]=>
int(3600)
["Caller"]=>
string(12) "123-123-1234"
["Callee"]=>
string(12) "123-123-1236"
}
}

The $classmap variable is a map between keys and values, where the keys are WSDL types
and the values are PHP class names. I recommend that you keep the names the same whenever
possible, as having multiple names for the same objects can become quite confusing.

Authentication


So now that you have developed a bit of an API, you may be thinking about authentication. Just
as when you’re developing web applications, you have several options for authenticating users:
HTTP authentication, communicated-key authentication, and client-certificate authentication.

HTTP Authentication.


The easiest way to authenticate users is to use simple HTTP authentication. You can enable
this using an .htaccess file, just as you would for any other resource, except that the client
must be modified to provide the access credentials automatically. This syntax is simple and is
demonstrated in Listing 20-5.

McArthur_819-9.book Page 305 Friday, February 29, 2008 8:03 AM

Free download pdf