Getting notified of new posts, updated posts, new timeline posts and all of those important notifications is key to running your Voxel themed directory. Twilio is powerful and very inexpensive to send texts out for important information. In order to do so, follow these instructions:
Be sure to replace all of the necessary information where needed including Account SID, Auth Token, Twilio number with leading country code, and the destination number with country code. Feel free to customize the message under the destination number to further enhance the message.
// Twilio credentials
$account_sid = 'YOUR_TWILIO_ACCOUNT_SID';
$auth_token = 'YOUR_TWILIO_AUTH_TOKEN';
$twilio_number = 'YOUR_TWILIO_PHONE_NUMBER';// The destination phone number and message content
$to_number = 'DESTINATION_PHONE_NUMBER';
$message_content = 'A post has been updated!';// Twilio API URL
$url = 'https://api.twilio.com/2010-04-01/Accounts/' . $account_sid . '/Messages.json';// Setup request to send json via POST
$data = array(
'From' => $twilio_number,
'To' => $to_number,
'Body' => $message_content
);
$post = http_build_query($data);// Set up cURL
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $account_sid . ':' . $auth_token);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);// Send the request and get the response
$response = curl_exec($ch);
$error = curl_error($ch);
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);// Close cURL session handle
curl_close($ch);// Check for errors and process the response
if ($error) {
error_log('Curl error: ' . $error);
} else {
// Process the response as needed
error_log('Twilio API response: ' . $response);
}