I have the following PHP script to send a verification text using Twilio:
<?php
require '/twilio-php-master/Twilio/autoload.php';
// Use the REST API Client to make requests to the Twilio REST API
use Twilio\Rest\Client;
$AccountSid = "xxx"; // Your Account SID from www.twilio.com/console
$AuthToken = "xxx"; // Your Auth Token from www.twilio.com/console
$client = new Client($AccountSid, $AuthToken);
$number = $_GET['num'];
$country = $_GET['country'];
$receivingPhone = "+2".$number;
$code = rand(100000, 999999);
$client->messages->create(
// the number you'd like to send the message to
$receivingPhone,
array(
// A Twilio phone number you purchased at twilio.com/console
'from' => '+12562947081',
// the body of the text message you'd like to send
'body' => $code
)
);
$object = new stdClass();
$object->num = $code;
echo json_encode($object);
?>
When I run it using http://localhost/sms.php?num=01115465467&country=Egypt and I change the directory for the autoload.php file to /Applications/XAMPP/xamppfiles/htdocs/twilio-php-master/Twilio/autoload.php (where it is installed on my computer), the script works fine. However, I uploaded it to a remote server, and tried using the directory /var/www/html/group1/twilio-php-master/autoload.php (where it is on the server) and running it on http://188.226.144.157/group1/sms.php?num=01115465467&country=Egypt, but my android app returns an error code of 500 when it tries to run the script.