承接 alagaccia/skebby 相关项目开发

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

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

alagaccia/skebby

最新稳定版本:v1.0.7

Composer 安装命令:

composer require alagaccia/skebby

包简介

Skebby API

README 文档

README

Package for using Skebby SMS gateway with Laravel projects.

Requirements

  • PHP >= 7.0
  • Laravel 8.x, 9.x, 10.x, or 11.x

Installation

Install this package using Composer:

composer require alagaccia/skebby

Publish Configuration (Optional)

The package will automatically register itself with Laravel. Optionally, you can publish the configuration file:

php artisan vendor:publish --tag=skebby-config

This will create config/skebby.php in your Laravel application.

Configuration

Add the following environment variables to your .env file:

SKEBBY_USER="your-skebby-username"
SKEBBY_PWD="your-skebby-password" 
SKEBBY_ALIAS="your-skebby-alias"
SKEBBY_QUALITY="TI"

Usage

Using the Facade

use Skebby;

// Send SMS
$result = Skebby::send('1234567890', 'Hello from Laravel!');

// Get account info
$info = Skebby::getInfo();

// Get remaining credits
$remaining = Skebby::getRemaining();

Using Dependency Injection

use AndreaLagaccia\Skebby\Skebby;

class SmsController extends Controller
{
    public function sendSms(Skebby $skebby)
    {
        $result = $skebby->send('1234567890', 'Hello from Laravel!');
        return response()->json($result);
    }
}

Direct Instantiation

use alagaccia\skebby\Skebby;

$skebby = new Skebby();
$result = $skebby->send('1234567890', 'Hello World!');

Advanced Usage

Error Handling

The package includes comprehensive error handling with custom exceptions:

use alagaccia\skebby\Skebby;
use alagaccia\skebby\Exceptions\SkebbyException;

try {
    $skebby = new Skebby();
    $result = $skebby->send('1234567890', 'Hello World!');
    echo "SMS sent successfully!";
} catch (SkebbyException $e) {
    echo "SMS sending failed: " . $e->getMessage();
    // Handle specific error codes
    if ($e->getCode() == 401) {
        echo "Authentication failed - check your credentials";
    }
}

Message Types

You can specify different message types when sending SMS:

use Skebby;

// Send with specific message type
$result = Skebby::send('1234567890', 'Hello!', Skebby::MESSAGE_CLASSIC_PLUS);

// Send with campaign name for tracking
$result = Skebby::send('1234567890', 'Hello!', null, 'Summer Campaign 2024');

// Send with both message type and campaign name
$result = Skebby::send('1234567890', 'Hello!', Skebby::MESSAGE_CLASSIC_PLUS, 'Summer Campaign 2024');

// Available message types:
// Skebby::MESSAGE_CLASSIC_PLUS  ('GP') - Classic Plus
// Skebby::MESSAGE_CLASSIC       ('TI') - Classic (default)
// Skebby::MESSAGE_BASIC         ('SI') - Basic
// Skebby::MESSAGE_EXPORT        ('EE') - Export
// Skebby::MESSAGE_ADVERTISING   ('AD') - Advertising

Credit Management

Check remaining credits for different message types:

use Skebby;

// Get remaining credits for current message type
$remaining = Skebby::getRemaining();

// Get remaining credits for specific message type
$remaining = Skebby::getRemaining(Skebby::MESSAGE_CLASSIC_PLUS);

// Get all remaining credits
$allCredits = Skebby::getAllRemainingCredits();
// Returns: ['GP' => 100, 'TI' => 200, 'SI' => 300, ...]

Authentication Cache

The package automatically caches authentication credentials for the duration of the request to improve performance:

use Skebby;

// Clear authentication cache if needed
Skebby::clearAuthCache();

Configuration Options

The configuration file supports the following options:

return [
    'SKEBBY_USER' => env('SKEBBY_USER'),
    'SKEBBY_PWD' => env('SKEBBY_PWD'),
    'SKEBBY_ALIAS' => env('SKEBBY_ALIAS'),
    'SKEBBY_QUALITY' => env('SKEBBY_QUALITY', 'TI'), // Default message type
];

API Reference

Skebby Class Methods

  • send(string $phone, string $message, ?string $messageType = null, ?string $campaignName = null): ?array
  • getInfo(): ?array - Get account information
  • getRemaining(?string $messageType = null): int - Get remaining credits
  • getAllRemainingCredits(): array - Get all remaining credits
  • login(): array - Authenticate with API
  • clearAuthCache(): void - Clear authentication cache

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: NLPL
  • 更新时间: 2022-01-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固