1. Go to this page and download the library: Download smsfire/php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
smsfire / php-sdk example snippets
//Load composer autoload file
e Smsfire\Exceptions\SmsfireException;
use Smsfire\Exceptions\HttpException;
try {
$user = 'myuser'; //Same user that is used to access Dashboard
$pass = 'mypass'; //Same password that is used to access Dashboard
$token = base64_encode("{$user}:{$pass}");
/**
* Pass base64 token on Message instance
* Check guide table of params
*/
$messagesService = new Messages($token);
$response = $messagesService->sendIndividual(
$to,
$text,
$from,
$customId,
$campaignId,
$flash,
$allowReply,
$scheduleTime,
$debug
);
/**
* Response as raw text
* Good to use when Debug option is true
*/
echo $response;
//Response with the statusCode of Http response
echo $response->statusCode();
//Response as json string
echo $response->__toJson();
//Response as object
print_r($response->__toObject());
//Response as array
print_r($response->__toArray());
} catch (SmsfireException $e) {
echo $e->getMessage();
} catch (HttpException $e) {
echo $e->getMessage();
} catch (Exception $e) {
echo $e->getMessage();
}
//Load composer autoload file
Smsfire\Exceptions\SmsfireException;
use Smsfire\Exceptions\HttpException;
try {
$user = 'myuser'; //Same user that is used to access Dashboard
$pass = 'mypass'; //Same password that is used to access Dashboard
$token = base64_encode("{$user}:{$pass}");
//Pass base64 token on Message instance
$messagesService = new Messages($token);
//Minimum of two items to use Bulk request
$destinations = [
[
'to' => '5511944556677',
'text' => 'My first message',
'customId' => 'abc-00001',
'flash' => true
],
[
'to' => '5565988887777',
'text' => 'My second message'
]
];
$response = $messagesService->sendBulk(
$destinations,
$campaignId,
$allowReply,
$scheduleTime,
$debug
);
/**
* Response as raw text
* Good to use when Debug option is true
*/
echo $response;
//Response with the statusCode of Http response
echo $response->statusCode();
//Response as json string
echo $response->__toJson();
//Response as object
print_r($response->__toObject());
//Response as array
print_r($response->__toArray());
} catch (SmsfireException $e) {
echo $e->getMessage();
} catch (HttpException $e) {
echo $e->getMessage();
} catch (Exception $e) {
echo $e->getMessage();
}
//Load composer autoload file
sfire\Exceptions\SmsfireException;
use Smsfire\Exceptions\HttpException;
try {
$debug = false; //Debug API request - DEFAULT: false
$user = 'myuser'; //Same user that is used to access Dashboard
$pass = 'mypass'; //Same password that is used to access Dashboard
$token = base64_encode("{$user}:{$pass}");
/**
* Pass base64 token on Inbox instance
* Check guide table of params
*/
$inboxServices = new Inbox($token);
$response = $inboxServices->getAll($debug);
/**
* Response as raw text
* Good to use when Debug option is true
*/
echo $response;
//Response with the statusCode of Http response
echo $response->statusCode();
//Response as json string
echo $response->__toJson();
//Response as object
print_r($response->__toObject());
//Response as array
print_r($response->__toArray());
//Handle empty inbox
if($response->statusCode() === 204) {
echo "Empty inbox";
}
} catch (SmsfireException $e) {
echo $e->getMessage();
} catch (HttpException $e) {
echo $e->getMessage();
} catch (Exception $e) {
echo $e->getMessage();
}
//Load composer autoload file
sfire\Exceptions\SmsfireException;
use Smsfire\Exceptions\HttpException;
try {
$debug = false; //Debug API request - DEFAULT: false
$user = 'myuser'; //Same user that is used to access Dashboard
$pass = 'mypass'; //Same password that is used to access Dashboard
$token = base64_encode("{$user}:{$pass}");
/**
* Pass base64 token on Inbox instance
* Check guide table of params
*/
$inboxServices = new Inbox($token);
$response = $inboxServices->getUnread($debug);
/**
* Response as raw text
* Good to use when Debug option is true
*/
echo $response;
//Response with the statusCode of Http response
echo $response->statusCode();
//Response as json string
echo $response->__toJson();
//Response as object
print_r($response->__toObject());
//Response as array
print_r($response->__toArray());
//Handle empty inbox
if($response->statusCode() === 204) {
echo "Empty inbox";
}
} catch (SmsfireException $e) {
echo $e->getMessage();
} catch (HttpException $e) {
echo $e->getMessage();
} catch (Exception $e) {
echo $e->getMessage();
}
//Load composer autoload file
msfire\Exceptions\SmsfireException;
use Smsfire\Exceptions\HttpException;
try {
$user = 'myuser'; //Same user that is used to access Dashboard
$pass = 'mypass'; //Same password that is used to access Dashboard
$token = base64_encode("{$user}:{$pass}");
/**
* Pass base64 token on Status instance
* Check guide table of params
*/
$messagesStatus = new Status($token);
$ids = "000001,000002,000003"; //Messages ids - Comma separated
$response = $messagesStatus->messageIds($ids, $debug);
/**
* Response as raw text
* Good to use when Debug option is true
*/
echo $response;
//Response with the statusCode of Http response
echo $response->statusCode();
//Response as json string
echo $response->__toJson();
//Response as object
print_r($response->__toObject());
//Response as array
print_r($response->__toArray());
//Handle empty result
if($response->statusCode() === 204) {
echo "Message id does not exist";
}
} catch (SmsfireException $e) {
echo $e->getMessage();
} catch (HttpException $e) {
echo $e->getMessage();
} catch (Exception $e) {
echo $e->getMessage();
}
//Load composer autoload file
msfire\Exceptions\SmsfireException;
use Smsfire\Exceptions\HttpException;
try {
$user = 'myuser'; //Same user that is used to access Dashboard
$pass = 'mypass'; //Same password that is used to access Dashboard
$token = base64_encode("{$user}:{$pass}");
/**
* Pass base64 token on Status instance
* Check guide table of params
*/
$messagesStatus = new Status($token);
$customIds = "myid0001,myid000002,myid000003"; //Custom ids - Comma separated
$response = $messagesStatus->customIds($customIds, $debug);
/**
* Response as raw text
* Good to use when Debug option is true
*/
echo $response;
//Response with the statusCode of Http response
echo $response->statusCode();
//Response as json string
echo $response->__toJson();
//Response as object
print_r($response->__toObject());
//Response as array
print_r($response->__toArray());
//Handle empty result
if($response->statusCode() === 204) {
echo "Custom id does not exist";
}
} catch (SmsfireException $e) {
echo $e->getMessage();
} catch (HttpException $e) {
echo $e->getMessage();
} catch (Exception $e) {
echo $e->getMessage();
}
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.