Read Subscriber (get)

Read Subscriber (get) | Get subscriber by id or email address.
<?php
//example PHP code to get a subscriber
//set values of person to get
$url_params['apiKey']="APIKEY_HERE";
$url_params['email']="example@email.com";
//Optional fields commented out below:
//You can get a subscriber by email or by id
//$url_params['id']="SUBSCRIBERID_HERE";

$url = 'http://apidomain.com/api2/subscriber';
$url = sprintf("%s?%s", $url, http_build_query($url_params));
 
//Uses CURL GET Request
$curl = curl_init($url);
curl_setopt ($curl, CURLOPT_CONNECTTIMEOUT, 100);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($curl);
curl_close ($curl);
echo $result;

//Parse the json to get return values. 
$parsed_result = json_decode($result,false);

echo "<br><br>Status: $parsed_result->status";
echo "<br>Message: $parsed_result->message";
echo "<br>Error Code: $parsed_result->errorcode";
echo "<br>Error Message: $parsed_result->errormessage";
echo "<br>Subscriber Id: ";
echo $parsed_result->data->id;
echo "<br>Subscriber Email:";
echo $parsed_result->data->email;
echo "<br>Subscriber First Name:";
echo $parsed_result->data->firstname;
?>