0% found this document useful (0 votes)
66 views3 pages

SMS Integration

The document discusses setting up an SMS notification service using the Infobip API. It provides steps to create an account, download libraries, set up files, and includes code to send SMS notifications by calling the Infobip API.

Uploaded by

johnmarkbitar0.0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views3 pages

SMS Integration

The document discusses setting up an SMS notification service using the Infobip API. It provides steps to create an account, download libraries, set up files, and includes code to send SMS notifications by calling the Infobip API.

Uploaded by

johnmarkbitar0.0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ITP 105 – System Integration and Architecture

Endterm Completion
SMS Integration
Note: Download the SMS Library.

UWAMP Download link:


https://drive.google.com/file/d/14FgI21bnRGFFe2UuWCufH6daTQGKkcJZ/view?usp=drive_link

1. Create account in Infobip to use sms notification service provider.

2. Create project: lastname-sms-portfolio

- Download the SMS library in the provide download link at the top.
- Copy the sms and extract library zip file to your project

3. Create index file in your project. (index.php)


4. Create sendSMS in your project. (sendSMS.php)

<?php

/**
* Send an SMS message by using Infobip API PHP Client.
*
* For your convenience, environment variables are already pre-populated with your account data
* like authentication, base URL and phone number.
*
* Please find detailed information in the readme file.
*/

// This line includes the autoload file, which loads all necessary classes and functions automatically.
require 'vendor/autoload.php';

// These lines import classes from the Infobip library, allowing the script to interact with Infobip's SMS API.
use Infobip\Api\SmsApi;
use Infobip\Configuration;
use Infobip\Model\SmsAdvancedTextualRequest;
use Infobip\Model\SmsDestination;
use Infobip\Model\SmsTextualMessage;

// These lines define the base URL and API key required to authenticate and interact with the Infobip API.
$BASE_URL = "yourAPIUrlBaseHere";
$API_KEY = " yourAPIKeyHere ";

// These lines define variables for the sender name, recipient phone number, and message text.
$SENDER = "InfoSMS";
$RECIPIENT = "recipient";
$MESSAGE_TEXT = "Text body!";

// This line creates a new instance of the Configuration class, passing the base URL and API key as
parameters.
$configuration = new Configuration(
host: $BASE_URL,
apiKey: $API_KEY
);

// This line creates a new instance of the SmsApi class, passing the configuration object as a parameter.
$sendSmsApi = new SmsApi(
config: $configuration
);
// This line creates a new instance of the SmsDestination class, specifying the recipient phone number.
$destination = new SmsDestination(
to: $RECIPIENT
);

// This line creates a new instance of the SmsTextualMessage class, specifying the destination(s), sender,
and message text.
$message = new SmsTextualMessage(
destinations: [ $destination],
from: $SENDER,
text: $MESSAGE_TEXT
);

//Send Sms notification


$request = new SmsAdvancedTextualRequest(
messages: [ $message]
);

// This line sends the SMS message(s) using the sendSmsMessage method of the SmsApi class and stores the
response in the $smsResponse variable.
$smsResponse = $sendSmsApi->sendSmsMessage($request);

// This line echoes JavaScript code to display an alert box with the message "Notification sent!". This
provides feedback to the user that the SMS notification has been sent successfully.
echo"<script>alert('Notification sent!')</script>";

?>

You might also like