bb_sign/app/Controllers/TestController.php
2024-06-27 13:53:27 +05:30

50 lines
1.6 KiB
PHP

<?php
namespace App\Controllers;
use CodeIgniter\Controller;
class TestController extends Controller
{
public function sendSms()
{
$apiKey = 'HgvlULWCIrs'; // Your API key
$mobileNumbers = '9894638731'; // Recipient mobile numbers
$DLTTemplateID = '1107171922342349877'; // DLT Template ID
$senderId = 'LDRAJ'; // Sender ID
$message = 'Dear Gowtham, 986532 is OTP to approve Service group for service name purposes.';
$serviceName = 'TEMPLATE_BASED'; // Service name
// URL encode the message
$encodedMessage = urlencode($message);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, "https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?APIKEY=$apiKey&MobileNo=$mobileNumbers&SenderID=$senderId&Message=$encodedMessage&ServiceName=$serviceName&DLTTemplateID=$DLTTemplateID");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
// Execute cURL request and get the response
$output = curl_exec($ch);
// Close cURL session
curl_close($ch);
// Output the response (for testing purposes)
return $this->response->setJSON(['response' => $output]);
}
public function sendUrl()
{
helper('url');
$signedUrl = generate_signed_url('protected-page', [], 36000);
// Send the $signedUrl to your client (e.g., via email)
return $this->response->setJSON(['url' => $signedUrl]);
}
public function protectedPage(){
echo "This is protectedPage";
}
}