Create Subscriber (post)

Create Subscriber (post) | Add a new subscriber.
<?php
//example PHP code to add a subscriber with option to send a triggered email
//set values of person to insert
$post_params['apiKey']="APIKEY_HERE";
$post_params['email']="example@email.com";
//Optional fields commented out below:
//listId can be one listid, or for multiple lists, pass a comma-delimited list of listIds
//$post_params['listId']="1";
//$post_params['listId']="1,2,3,4"; 
//$post_params['firstname']="FIRSTNAME_HERE";
//$post_params['lastname']="LASTNAME_HERE";
//$post_params['mobile_phone']="9999999999";
//$post_params['email_type']="1";
//$post_params['unsubscribe']="0";
//$post_params['sms_unsubscribe']="0";
//$post_params['customfields']='{"custom1": "CUSTOMFIELD_VALUE_HERE", "custom2": "CUSTOMFIELD_VALUE_HERE"}';
//triggered id of email to send - must be a email that was already sent.
//do NOT include the <triggeredid> field if you only want to add a subscriber and not trigger an email
//$post_params['triggeredid']="0";

$url = 'http://apidomain.com/api2/subscriber';
 
//Posts this using CURL
$curl = curl_init($url);
curl_setopt ($curl, CURLOPT_POST, 1);
curl_setopt ($curl, CURLOPT_POSTFIELDS, $post_params);
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->emailid;
echo $parsed_result->data->id;
echo "<br>Subscriber Email:";
echo $parsed_result->data->email;
echo "<br>Subscriber First Name:";
echo $parsed_result->data->firstname;
?>