The easiest way to install is by using Composer:
composer require hivelink/php
Composer is a dependency manager for PHP which allows you to declare the libraries your project depends on, and it will manage (install/update) them for you. If you are not familiar with Composer, you can read its documentations and download it via getcomposer.org.
Alternatively you can download HiveLink SDK from here and extract it in your project and follow the rest of the instructions below. Also there is an Example folder inside the package which you can use to understand the procedure.
To use the API, you need an API key. To get that you should have a Hivelink account. Register and get your API key.
Then require the file autoload.php to get all classes and dependencies loaded.
require __DIR__ . '/vendor/autoload.php';
Create an instance from Hivelink class with your API key:
$api = new \Hivelink\HivelinkApi( 'your_api_key');
Don't forget to change your_api_key with the key you have got from your Hivelink account.
Send a sms:
$api->SendSimple(
"09xxxxxxxxx", // receiver
"9000xxxxx", // choose a line number from your account
"This is a test!Hivelink", // message
);
| Parameter | Required | Description | Type | Example |
|---|---|---|---|---|
| text | Yes | Text to be sent | string | Hello, World! |
| receiver | Yes | The number of the receiver(s) of the message (set all receiver in array). | string | 09110000000 |
| line_number | No | If the sender's number is not specified, the message will be selected from Highlink's dedicated lines with higher priority.(If you have specified lines, enter the desired line |
string | 9000**** |
| date | No | The exact date and time of sending the message based on Unix time, if not specified, the message will be sent instantly. | string | 1671148877 |
Here is a sample code for sending an SMS. Please note that if you are looking for a specific line, you must specify the line number.
require __DIR__ . '/vendor/autoload.php';
try{
$message = "This is a test!Hivelink";
$lineNumber = null; // If you do not enter the line number, the message will be sent from the fastest HiveLink service line
$receiver = "091xxxxxxxx"; // Use this method if sending to a mobile number
$receiver = array("091********","092********"); // Use this method if sending to multiple mobile numbers
$api = new \HiveLinkLib\HivelinkApi('api_key_developer');
$api->SendSimple($lineNumber,$receiver,$message);
}
catch(\HiveLinkLib\Exceptions\ApiException $e){
//If the response to the request is unsuccessful, this section will work
echo $e->errorMessage();
}
catch(\HiveLinkLib\Exceptions\HttpException $e){
//If there is a problem in communicating with the HiveLink web service, this section will work
echo $e->errorMessage();
}
Freely distributable under the terms of the MIT license.
composer require hivelink/php
require __DIR__ . '/vendor/autoload.php';
$api = new \Hivelink\HivelinkApi('your_api_key');
$api->SendSimple(
"09xxxxxxxxx", // گیرنده پیام
"9000xxxxx", // انتخاب خط ارسال کننده پیام ، در صورت وارد نکردن از خط با سرعت بالا استفاده میشود!
"This is a test!Hivelink", // message
);
require __DIR__ . '/vendor/autoload.php';
try{
$message = "این یک تست می باشد!هایولینک";
$lineNumber = null; // اگر شماره خط را وارد نکنید، پیام از سریعترین خط سرویس هایولینک ارسال می شود
$receiver = "091xxxxxxxx";
$api = new \Hivelink\HivelinkApi('کلید توسعه دهنده');
$api->SendSimple($lineNumber,&receiver,$message);
}
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?