<?php
//=============================================================================
// Call a Web Service
//=============================================================================

    error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE);      //all except warnings & notices

    $url = 'workshop.sps.nyu.edu/~sultans/util/rest/RESTaddrbook.py';

    $lastname = $_GET['lname'];                         #get studentId parameter
    
    if (! $lastname)  $lastname = 'Sul';

    $url2 = $url . '?' . 'lname=' . $lastname;          #append the id to end of param

//  $data = file_get_contents($url2);                   #retrieve the url - No longer works for https

	$c = curl_init($url);
	curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
	$data = curl_exec($c);
	curl_close($c);

//	print ("<br> result $data");						//for debugging

    $array = json_decode($data);                        #convert JSON string into nested PHP array
    
    print('<pre>');
    print($data); 
    print('</pre>');
?>