PHP Snippet 2:
// conditions to send sms
$data = array('username' => $username, 'apikey' => $apikey, 'numbers' => $mobile, "sender" => $sender, "message" => $msg);
if($this->sms_env == true)
{
$ch = curl_init('https://api.textlocal.in/send?');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$response = curl_exec($ch);
$decoded_response = json_decode($response, true);
curl_close($ch);
$sms_status = @$decoded_response['status'];
$status['sms'] = $sms_status;
}
$db_data = array(
'sms_response' => @$response,
'unique_code' => @$unique_code,
'mobile_no' => @$mobile,
'message' => @$msg,
'username' => $username,
'apikey' => $apikey,
'sender_id' => $sender
);
return $db_data;