hivelink/laravel
Laravel SDK for Hivelink SMS and Inquiry API. Install via Composer, register the service provider/facade, publish config, and set your API key. Send SMS with Hivelink::SendSimple and handle API/HTTP exceptions.
First of all you will ned an API Key . You can get one Here.
composer require hivelink/laravel
Head to config/app.php and add this line to the end of providers Array:
Hivelink\Laravel\ServiceProvider::class,
So that array must me something like this:
'providers' => [
/*
* Laravel Framework Service Providers...
*/
.
.
.
Hivelink\Laravel\ServiceProvider::class
]
Then in the config/app.php and add this line to the end of aliases Array:
'Hivelink' => Hivelink\Laravel\Facade::class,
Run this command in your project dirctory:
php artisan vendor:publish --provider="Hivelink\Laravel\ServiceProvider" --tag="config"
In the message appear, find the number of Hivelink, enter the related number then hit Enter.
Now you must define your API Key to project. for this head to config/hivelink.php then put your API KEY in the code:
<?php
return [
'apikey' => ' ',
];
You can use the package where ever you want.
use Hivelink;
Then use this pattern to send SMS:
try{
$sender = "9000****";
$message = "این یک پیام تست می باشد";
$receiver = array("090********");
$result = Hivelink::SendSimple($sender,$receiver ,$message);
if($result){
foreach($result as $r){
var_dump($r)
}
}
}
catch(\Hivelink\Exceptions\ApiException $e){
echo $e->errorMessage();
}
catch(\Hivelink\Exceptions\HttpException $e){
echo $e->errorMessage();
}catch(\Exceptions $ex){
echo $ex->getMessage()
}
Use this method get account balanced :
try{
$result = Hivelink::getCredit();
if($result){
var_dump($result);
}
}
catch(\Hivelink\Exceptions\ApiException $e){
echo $e->errorMessage();
}
catch(\Hivelink\Exceptions\HttpException $e){
echo $e->errorMessage();
}
How can I help you explore Laravel packages today?