textlk/textlk-laravel

Text.lk - SMS Gateway Sri Lanka

Installs: 35

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/textlk/textlk-laravel

v1.1.0 2025-12-31 10:58 UTC

README

Latest Version on Packagist Total Downloads License

Official Laravel / PHP SDK for sending SMS via Text.lk ๐Ÿš€

PHP Version Laravel

Easily integrate Text.lk SMS services into your Laravel or PHP applications.

โœจ Features

  • Send SMS messages via Text.lk API
  • Supports single & multiple recipients
  • Plain text SMS support
  • Scheduled SMS support
  • Check account balance
  • Fetch account profile
  • Lightweight & simple API

๐Ÿ“ฆ Installation

Install the package via Composer:

composer require textlk/textlk-laravel

โš™๏ธ Configuration

1. Get your API Key

Login to your Text.lk Dashboard and generate an API key.

2. Laravel Environment (.env)

Add your API key to .env:

TEXTLK_API_KEY=your_api_key_here

๐Ÿš€ Usage

Laravel Example

use TextLK\SMS;

$SMS = new SMS(config('services.textlk.api_key'));

$data = [
    "recipient" => "9476000000", // or "+9476000000,+9476111000"
    "sender_id" => "TEXTLK",
    "type" => "plain",
    "message" => "Boom! Message from Text.lk"
    // "schedule_time" => "2021-12-20T07:00:00Z"
];

$response = $SMS->send($data);

return $response;

๐Ÿงช Plain PHP Example (example.php)

<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);

require '../vendor/autoload.php';

use TextLK\SMS;

// Set your API key
$api_key = 'YOUR_API_KEY';

// Instantiate SMS class
$SMS = new SMS($api_key);

$data = [
    "recipient" => "9476000000", // or "+9476000000,+9476111000"
    "sender_id" => "TEXTLK",
    "type" => "plain",
    "message" => "Boom! Message from Text.lk"
    // "schedule_time" => "2021-12-20T07:00:00Z"
];

echo $SMS->send($data);

// echo $SMS->getBalance();
// echo $SMS->getProfile();

๐Ÿ“ค Send SMS Parameters

Parameter Required Description
recipient โœ… Yes Mobile number(s), comma separated
sender_id โœ… Yes Approved Sender ID
type โœ… Yes plain
message โœ… Yes SMS content
schedule_time โŒ No ISO 8601 datetime (UTC)

๐Ÿ’ฐ Check SMS Balance

$balance = $SMS->getBalance();

๐Ÿ‘ค Get Account Profile

$profile = $SMS->getProfile();

๐Ÿงฉ Laravel Service Configuration (Optional)

Add to config/services.php:

'textlk' => [
    'api_key' => env('TEXTLK_API_KEY'),
],

๐Ÿ” Security Notes

  • Never commit your API key to GitHub
  • Always store credentials in .env
  • Use HTTPS when calling APIs

๐Ÿง‘โ€๐Ÿ’ป Support

๐Ÿ“„ License

MIT License ยฉ Text.lk