-
-
Save daveh/6a31d0d28d9aef8c161c6ff1b6d29fae to your computer and use it in GitHub Desktop.
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>PHP SMS</title> | |
<meta charset="UTF-8" /> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css" /> | |
</head> | |
<body> | |
<h1>PHP SMS</h1> | |
<form method="post" action="send.php"> | |
<label for="number">Number</label> | |
<input type="text" name="number" id="number" /> | |
<label for="message">Message</label> | |
<textarea name="message" id="message"></textarea> | |
<fieldset> | |
<legend>Provider</legend> | |
<label> | |
<input type="radio" name="provider" value="infobip" checked /> Infobip | |
</label> | |
<br /> | |
<label> | |
<input type="radio" name="provider" value="twilio" /> Twilio | |
</label> | |
</fieldset> | |
<button>Send</button> | |
</form> | |
</body> | |
</html> |
<?php | |
use Infobip\Configuration; | |
use Infobip\Api\SmsApi; | |
use Infobip\Model\SmsDestination; | |
use Infobip\Model\SmsTextualMessage; | |
use Infobip\Model\SmsAdvancedTextualRequest; | |
use Twilio\Rest\Client; | |
require __DIR__ . "/vendor/autoload.php"; | |
$number = $_POST["number"]; | |
$message = $_POST["message"]; | |
if ($_POST["provider"] === "infobip") { | |
$base_url = "https://your-base-url.api.infobip.com"; | |
$api_key = "your API key"; | |
$configuration = new Configuration(host: $base_url, apiKey: $api_key); | |
$api = new SmsApi(config: $configuration); | |
$destination = new SmsDestination(to: $number); | |
$message = new SmsTextualMessage( | |
destinations: [$destination], | |
text: $message, | |
from: "daveh" | |
); | |
$request = new SmsAdvancedTextualRequest(messages: [$message]); | |
$response = $api->sendSmsMessage($request); | |
} else { // Twilio | |
$account_id = "your account SID"; | |
$auth_token = "your auth token"; | |
$client = new Client($account_id, $auth_token); | |
$twilio_number = "+ your outgoing Twilio phone number"; | |
$client->messages->create( | |
$number, | |
[ | |
"from" => $twilio_number, | |
"body" => $message | |
] | |
); | |
} | |
echo "Message sent."; |
How do i make my name display when receiver receives the sms
When i send rather than getting Mutual i got InfoSMS
$message = new SmsTextualMessage(
destinations: [$destination],
text: $message,
from: "Mutual"
Its saying message sent but not getting any message😕🤦🏻
@edwardklem Check the provider's dashboard for the sending logs
its not working right now
Fatal error: Uncaught ArgumentCountError: Too few arguments to function PHPStan\PhpDocParser\Lexer\Lexer::__construct(), 0 passed in C:\xampp\htdocs\BAWASLA\vendor\symfony\type-info\TypeResolver\StringTypeResolver.php on line 66 and exactly 1 expected in C:\xampp\htdocs\BAWASLA\vendor\phpstan\phpdoc-parser\src\Lexer\Lexer.php:102 Stack trace: #0 C:\xampp\htdocs\BAWASLA\vendor\symfony\type-info\TypeResolver\StringTypeResolver.php(66): PHPStan\PhpDocParser\Lexer\Lexer->__construct() #1 C:\xampp\htdocs\BAWASLA\vendor\symfony\type-info\TypeResolver\TypeResolver.php(71): Symfony\Component\TypeInfo\TypeResolver\StringTypeResolver->__construct() #2 C:\xampp\htdocs\BAWASLA\vendor\symfony\type-info\TypeResolver\TypeResolver.php(66): Psr\Container\ContainerInterface@anonymous->__construct() #3 C:\xampp\htdocs\BAWASLA\vendor\symfony\property-info\Extractor\ReflectionExtractor.php(102): Symfony\Component\TypeInfo\TypeResolver\TypeResolver::create() #4 C:\xampp\htdocs\BAWASLA\vendor\infobip\infobip-api-php-client\Infobip\ObjectSerializer.php(60): Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor->__construct() #5 C:\xampp\htdocs\BAWASLA\vendor\infobip\infobip-api-php-client\Infobip\Api\SmsApi.php(77): Infobip\ObjectSerializer->__construct() #6 C:\xampp\htdocs\BAWASLA\send_sms.php(21): Infobip\Api\SmsApi->__construct(Object(Infobip\Configuration)) #7 {main} thrown in C:\xampp\htdocs\BAWASLA\vendor\phpstan\phpdoc-parser\src\Lexer\Lexer.php on line 102
Hii