ahmed-aliraqi/expert-texting-sms

ExpertTexting REST API为Laravel应用程序提供了发送短信和Unicode消息、读取未读消息、检查账户余额等功能。ExpertTexting API通过HTTPS提供。为确保数据隐私,不支持未加密的HTTP。

1.0.1 2017-05-03 16:00 UTC

This package is auto-updated.

Last update: 2024-08-29 03:36:48 UTC


README

ExpertTexting REST API为Laravel应用程序提供了发送短信和Unicode消息、读取未读消息、检查账户余额等功能。ExpertTexting API通过HTTPS提供。为确保数据隐私,不支持未加密的HTTP。

文档

安装

  • 首先在ExpertTexting中创建一个新账户
    https://www.experttexting.com/appv2/

      composer require ahmed-aliraqi/expert-texting-sms
    
  • 将提供者类添加到config文件夹中的app.php文件。

      Aliraqi\ET\ServiceProvider::class,
    
  • 添加别名类

      'SMS' => Aliraqi\ET\SMSFasade::class,
    
  • 然后从终端调用此命令

      php artisan vendor:publish
    

    您可以从项目中的此路径获取此文件 config/sms_et.php

      return [
          /**
           * All requests require your user credentials & API key, which you can find under "Account Settings"
           * in [https://www.experttexting.com/appv2/Dashboard/Profile] .
           */
          'username' => '', // Required. Your ET username. Ex: starcity
      
          'password' => '', // Required. Your ET password. Ex: StarCity123
      
          'api_key' => '',  // Required. Your API key. Ex: sswmp8r7l63y
      ];
    

用法

  • 发送文本或Unicode消息。

      $sms = SMS::from('YourName')
      	->to('PhoneNumber')
      	->Message('Hello World')
      	->send();
      
      // Get response object.
      dd($sms->getResponse());
    

    结果

      {
         "Response": {
            "message_id": "671729375",
            "message_count": 1,
            "price": 0.0085
         },
         "ErrorMessage": "",
         "Status": 0
      }
    
  • 搜索具有给定消息ID的先前发送的消息。

      SMS::getStatus($messageId)->getResponse();
    
  • 列出所有未读收到的消息。

      SMS::getUnreadInbox()->getResponse();
    
  • 检索您的当前账户余额。

      SMS::getBalance()->getResponse();