承接 labsmobile/sms-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

labsmobile/sms-php

Composer 安装命令:

composer require labsmobile/sms-php

包简介

Send SMS messages through the LabsMobile platform and the PHP library.

README 文档

README

LabsMobile-PHP

Send SMS messages through the LabsMobile platform and the PHP library.

Documentation

  • Labsmobile API documentation can be found here.

Features

  • Send SMS messages.
  • Get account credits
  • Get prices by country
  • Manage scheduled sendings
  • HLR Request (Check mobile)

Requirements

  • A user account with LabsMobile. Click on the link to create an account here.
  • This library supports php v5.4 and higher versions of php.
  • From php v5.4 to php v7.1 it is recommended to use Composer 2.2.22.

Installation

To install the labsmobile/sms-php library, it is recommended to use composer.

Installation command

composer require labsmobile/sms-php

Installation by modifying the composer.json file

"require": {
	"labsmobile/sms-php": "1.0.2"
}

Examples of use cases

Send SMS

Here is an example of using the library to send a SMS:

  public $username = 'myusername';
  public $token = 'mytoken';

  public function testSms()
  { 
    try {
      $message = 'Test SMS';
      $phone = ['34XXXXXXXXX'];
      $labsMobileClient = new LabsMobileClient($this->username, $this->token);
      $bodySms = new LabsMobileModelTextMessage($phone,$message);
      $labsMobileClient = $labsMobileClient->sendSms($bodySms);
      $body = $labsMobileClient->getBody();
      $json = json_decode($body);
      self::assertSame('0',$json->code);
    } catch (RestException $exception) {
      self::assertSame('Error', $exception->getStatus() ." ". $exception->getMessage());
    }
  }

Get account credits

Here is an example to learn credits for an existing account:

  public $username = 'myusername';
  public $token = 'mytoken';

  public function testGetCredits()
  {
    try{
      $labsMobileClient = new LabsMobileClient($this->username, $this->token);
      $response = $labsMobileClient->getCredit();
      $body = $response->getBody();
      $json = json_decode($body);
      self::assertSame(0,$json->code);
    } catch(RestException $exception) {
      self::assertSame('Error', $exception->getStatus() ." ". $exception->getMessage());
    }
  }

Manage scheduled sendings

Here is an example you can cancel or execute the scheduled sendings that are pending for execution:

  public $username = 'myusername';
  public $token = 'mytoken';

  public function testScheduledSendings() 
  {
    try {
      $subid="XXXXXXXXXX";
      $cmd="XXXX";
      $labsMobileClient = new LabsMobileClient($this->username, $this->token);
      $bodyScheduled = new LabsMobileModelScheduledSendings($subid, $cmd);
      $labsMobileClient = $labsMobileClient->scheduledSendings($bodyScheduled);
      $body = $labsMobileClient->getBody();
      $json = json_decode($body);
      self::assertSame(0,$json->code);
    } catch (RestException $exception) {
      self::assertSame('Error', $exception->getStatus() ." ". $exception->getMessage());
    }
  }

Get prices by country

Here is an example to know the credits that a single sending will take depending on the country of delivery:

  public $username = 'myusername';
  public $token = 'mytoken';

  public function testCountryPrice()
  {
    try {
      $countries = ["CO","ES"];
      $labsMobileClient = new LabsMobileClient($this->username, $this->token);
      $bodyContries = new LabsMobileModelCountryPrice($countries);
      $labsMobileClient = $labsMobileClient->getpricesCountry($bodyContries);
      $body = $labsMobileClient->getBody();
      self::assertTrue(true, $body);
    } catch (RestException $exception) {
      self::assertSame('Error', $exception->getStatus() ." ". $exception->getMessage());
    }
    
  }

HLR Request

Here is an example queries the mobile phone status with the related information like current operator, format, active, ported information, subscription country, etc:

public $username = 'myusername';
  public $token = 'mytoken';

  public function testHlr()
  {
    try {
      $numbers = [];//[34XXXXXXXX,34XXXXXXXX]
      $labsMobileClient = new LabsMobileClient($this->username, $this->token);
      $bodyHlr = new LabsMobileModelHlrRequest(json_encode($numbers));
      $labsMobileClient = $labsMobileClient->hlrRequest($bodyHlr);
      $body = $labsMobileClient->getBody();
      $json = json_decode($body);
      self::assertSame('ok', $json->result);
    } catch (RestException $exception) {
      self::assertSame('Error', $exception->getStatus() ." ". $exception->getMessage());
    }
  }

Help

If you have questions, you can contact us through the support chat or through the support email support@labsmobile.com.

labsmobile/sms-php 适用场景与选型建议

labsmobile/sms-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.83k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 12 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「composer」 「sms」 「smsapi」 「httpclient」 「labsmobile」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 labsmobile/sms-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 labsmobile/sms-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 labsmobile/sms-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 6.83k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-11