hivelink/php
Composer 安装命令:
composer require hivelink/php
包简介
HiveLink Operator Library for PHP!
README 文档
README
HiveLink Library Php
Easy-to-use SDK for implementing Hivelink SMS API in your PHP projects.
Explore the docs »
English Document | مستندات فارسی
Table of Contents
Install
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.
usage
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 );
Parameters
| 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 |
Example
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(); }
License
Freely distributable under the terms of the MIT license.
فهرست مطالب
نصب
سادهترین راه برای نصب این پکیج استفاده از Composer است:
composer require hivelink/php
نحوه استفاده
برای استفاده از این پکیج میبایست API key داشته باشید. جهت دریافت ابتدا در سامانه جامع هایولینک ثبتنام کنید و از پنل کاربریتان API key دریافت کنید.
سپس باید فایل autoload را به پروژهی خود اضافه کنید:
require __DIR__ . '/vendor/autoload.php';
یک instance از کلاس Hivelink با API key خود بسازید:
$api = new \Hivelink\HivelinkApi('your_api_key');
به خاطر داشته باشید که your_api_key را با کلید دریافتی از حساب هایولینک خود جایگزین کنید.
پیامک دلخواهتان را ارسال کنید:
$api->SendSimple( "09xxxxxxxxx", // گیرنده پیام "9000xxxxx", // انتخاب خط ارسال کننده پیام ، در صورت وارد نکردن از خط با سرعت بالا استفاده میشود! "This is a test!Hivelink", // message );
پارامترها
| پارامتر | اجباری | توضیحات | نوع | مثال |
|---|---|---|---|---|
| text | بله | متنی که باید ارسال شود. | string | این یک تست می باشد! |
| receiver | بله | شماره گیرنده پیام می باشد. | string | 09110000000 |
| line_number | خیر | اگر شماره فرستنده مشخص نشده باشد، پیام از خطوط اختصاصی هایولینک با اولویت بالاتر انتخاب می شود.(در صورت داشتن خطوط مشخص، خط مورد نظر را وارد کنید) | string | 9000*** |
| date | خیر | تاریخ و زمان دقیق ارسال پیام بر اساس Unixtime می باشد که اگر قید نشود در همان لحظه پیام ارسال می شود. | string | 1671147631 |
نمونه کد
در اینجا یک نمونه کد برای ارسال پیامک آورده شده است. لطفا توجه داشته باشید که اگر به دنبال یک خط خاص هستید، باید "شماره خط" را مشخص کنید.
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(); }
hivelink/php 适用场景与选型建议
hivelink/php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 222 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 11 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「sms」 「otp」 「hivelink」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 hivelink/php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hivelink/php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 hivelink/php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
Extensible library for building notifications and sending them via different delivery channels.
OTP generating package
yii2-sms expand
OTP generating package
统计信息
- 总下载量: 222
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-11-07