patricpoba/arkesel-php

此包允许您通过 https://sms.arkesel.com 作为服务提供商,从您的laravel应用程序发送短信。

v1.0.4 2023-06-06 17:14 UTC

This package is auto-updated.

Last update: 2024-09-17 18:12:59 UTC


README

此包允许您通过 https://sms.arkesel.com 作为服务提供商,从您的laravel应用程序发送短信。

需求与安装

此包需要至少php 7.0 或laravel 5.5。您可以通过composer安装此包。

composer require patricpoba/arkesel-php

PHP使用

// PHP Examples

use PatricPoba\Arkesel\Sms;

$sms = new Sms('SenderId', 'smsApiKey');
  

## Basic sending(uses api_key set in .env file)
// successful response: {"code":"ok","message":"Successfully Send","balance":17706,"user":"Yaw Berko"}
// error response: {"code":"102","message":"Authentication Failed"} 
$sms->send('02XXXXXXXXX', 'Testing sms messaging');

## To use a different api key at runtime,
$sms->setApiKey('API_KEY_GOES_HERE')->send('02XXXXXXXX', 'Testing App');

## To customise sender Id (must not be more than 11 characters)
$sms->from('CompanyName')->send('02XXXXXXXX', 'Testing App');

## Sceduling (sending message at a later time)
// successful response: {"code":"109","message":"Invalid Schedule Time"} 
// successful response: {"code":"ok","message":"SMS Scheduled successfully.","balance":17705,"user":"Yaw Berko"}
$dateTime ='04-05-2020 06:19 PM'; // Must be this format - "d-m-Y h:i A" 
$sms->schedule($dateTime, '02XXXXXXXX', 'This message will be sent later')
 
## Checking Sms balance    
// successful response: {"balance":17707,"user":"Yaw Berko","country":"Ghana"}
$sms->balance();

## Check balance of a different a arkesel account account,
$sms->setApiKey('API_KEY_GOES_HERE')->balance();

Laravel

如果您使用的是laravel 5.5及以上版本,您可以跳过此步骤并继续查看示例。将以下行代码添加到 config/app.php 文件中的 providers 数组

PatricPoba\Arkesel\ArkeselServiceProvider::class

将此包的facade添加到 config/app.php 文件中的 aliases 数组

 'ArkeselSms' => PatricPoba\Arkesel\ArkeselSmsFacade::class

使用示例

# Setting API key in .env file
Before you can start sending sms you will need to set your api key and default sender ID in your /.env file
You can find your api key here `https://sms.arkesel.com/user/sms-api/info` 
These config files can be changed  from the laravel application.  

<!-- /.env file --> 
ARKESEL_SMS_SENDER_ID=MyApp
ARKESEL_SMS_API_KEY=YourKeyGoesHere


## Sending Sms 
 
## Basic sending(uses api_key set in .env file)
 * successful response: {"code":"ok","message":"Successfully Send","balance":17706,"user":"Yaw Berko"}
 * error response: {"code":"102","message":"Authentication Failed"} 
 * */
 
ArkeselSms::send('02XXXXXXXXX', 'Testing sms messaging');

## To use a different api key at runtime,
ArkeselSms::setApiKey('API_KEY_GOES_HERE')->send('02XXXXXXXX', 'Testing App');


## To customise sender Id (must not be more than 11 characters)
ArkeselSms::from('CompanyName')->send('02XXXXXXXX', 'Testing App');


## Sceduling (sending message at a later time) 
// successful response: {"code":"109","message":"Invalid Schedule Time"} 
// successful response: {"code":"ok","message":"SMS Scheduled successfully.","balance":17705,"user":"Yaw Berko"}

$dateTime ='04-05-2020 06:19 PM'; // Must be this format - "d-m-Y h:i A" 
ArkeselSms::schedule($dateTime, '02XXXXXXXX', 'This message will be sent later')

 
## Checking Sms balance   
// successful response: {"balance":17707,"user":"Yaw Berko","country":"Ghana"}

ArkeselSms::balance();


## Check balance of a different a arkesel account account,
ArkeselSms::setApiKey('API_KEY_GOES_HERE')->balance();

安全

如果您发现任何安全相关的问题,请通过 twitter 发送消息给我,而不是使用问题跟踪器。

许可协议

MIT许可(MIT)。有关更多信息,请参阅 许可文件