Nusa SMS Laravel Service

Overview

Nusa SMS Laravel Service

The service covers all the NusaSMS's API calls endpoint. This service is still in development. Feel free to contribute!

Complete documentation:

https://apidoc.nusasms.com/

Usage

  1. Download or clone this project.
  2. Put this project to your Laravel project directory.
  3. Set the .env as following:
    NUSASMS_ENV=development
    # or set NUSASMS_ENV to production
    NUSASMS_URL=https://api.nusasms.com
    NUSASMS_DEV_URL=https://dev.nusasms.com
    NUSASMS_API_KEY=<yourApiKey>
    NUSASMS_DEV_KEY=DEV_TESTING_API_KEY

What has been covered:

  • Get user data using API key
  • Get balance data
  • WhatsApp Send base64 Media
  • WhatsApp Send message
  • WhatsApp Message Info
  • WhatsApp Delivery Status Callback
  • WhatsApp Push Inbox
  • SMS Send Plain
  • SMS Send Group
  • SMS Command
  • SMS Push Inbox
  • SMS Delivery Status Callback

Usage

Get user data using API key:



use \App\Services\NusaSms;

return response()->json(NusaSms::getUser());

Success response example:

{
  "error": false,
  "error_code": 0,
  "message": "APIKey Authentication check",
  "data": {
    "userid": "cdev_testing_user",
    "idPerson": 1000001,
    "idClient": 1000001
  }
}

Get balance data:



use \App\Services\NusaSms;

return response()->json(NusaSms::getBalance());

Success response example:

{
  "error": false,
  "error_code": 0,
  "message": "Client credit data",
  "data": {
    "idClient": 1000001,
    "wa_balance": 1000,
    "wa_expired_date": "2020-01-01",
    "hlr_balance": 0,
    "hlr_expired_date": null,
    "sim_balance": 0,
    "sim_expired_date": null,
    "sms_balance": 782,
    "sms_expired_date": "2020-12-05",
    "pulsa_balance": null
  }
}

WhatsApp Send Media:

There are few notes regarding the usage of this API:

  1. The $request parameter is an instance of \Illuminate\Http\Request. It is made for Laravel.
  2. The file passed to the $request is could be anything, but are limited to 512KB of size.
  3. If there are multiple file passed, the API will simply won't work. So make sure it is ONE file.
  4. The "file" key could be anything.


use \App\Services\NusaSms;

NusaSms::setCaption('Halo');
NusaSms::setSender('6281243214321'); // This is optional, if not set, the NusaSMS's default sender will be used.
NusaSms::setMediaAsBase64($request);

return response()->json(NusaSms::waSendBase64Media('6281212341234'));

Success response example:

{
  "error": false,
  "error_code": 0,
  "message": "WA Send Media",
  "data": {
    "sender": "6281243214321",
    "queue": null,
    "destination": "6281212341234",
    "caption": "Halo",
    "media_url": "https://dev.nusasms.com/assets/Screenshot_20220128_224647.png",
    "ref_no": "933050291643303204"
  }
}

Invalid WA Sender response example:

{
  "error": true,
  "message": "Invalid WA Sender",
  "description": null
}

Invalid destination response example:

{
  "detail": [
    {
      "loc": [
        "body",
        "destination"
      ],
      "msg": "Invalid destination format",
      "type": "value_error"
    },
    {
      "loc": [
        "body",
        "__root__"
      ],
      "msg": "argument of type 'NoneType' is not iterable",
      "type": "type_error"
    }
  ]
}

File exceeds limit of 512KB size

{
  "error": true,
  "message": "File exceed limits (max 512 KB)",
  "description": null
}

WhatsApp Send Media URL:

json(NusaSms::waSendBase64Media('6281212341234'));">


use \App\Services\NusaSms;

NusaSms::setCaption('Halo');
NusaSms::setSender('6281243214321'); // This is optional, if not set, the NusaSMS's default sender will be used.
NusaSms::setUrlMedia("https://upload.wikimedia.org/wikipedia/commons/thumb/9/9f/Flag_of_Indonesia.svg/255px-Flag_of_Indonesia.svg.png");

return response()->json(NusaSms::waSendBase64Media('6281212341234'));

Success response example:

{
  "error": false,
  "error_code": 0,
  "message": "WA Send Media",
  "data": {
    "sender": "6281243214321",
    "queue": null,
    "destination": "6281212341234",
    "caption": "Halo",
    "media_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/9/9f/Flag_of_Indonesia.svg/255px-Flag_of_Indonesia.svg.png",
    "ref_no": "644724881642721371"
  }
}

Invalid WA Sender response example:

{
  "error": true,
  "message": "Invalid WA Sender",
  "description": null
}

Invalid destination response example:

{
  "detail": [
    {
      "loc": [
        "body",
        "destination"
      ],
      "msg": "Invalid destination format",
      "type": "value_error"
    },
    {
      "loc": [
        "body",
        "__root__"
      ],
      "msg": "argument of type 'NoneType' is not iterable",
      "type": "type_error"
    }
  ]
}

File exceeds limit of 512KB size

{
  "error": true,
  "message": "File exceed limits (max 512 KB)",
  "description": null
}

WhatsApp Send Message:

json(NusaSms::waSendMessage('6281212341234'));">


use \App\Services\NusaSms;

NusaSms::setMessage("Hello, world!");
NusaSms::setSender('6281243214321'); // This is optional, if not set, the NusaSMS's default sender will be used.

return response()->json(NusaSms::waSendMessage('6281212341234'));

Success response example:

{
  "error": false,
  "error_code": 0,
  "message": "WA send message",
  "data": {
    "sender": "6281243214321",
    "queue": null,
    "destination": "6281212341234",
    "message": "Hello, world!",
    "ref_no": "008078391643125660"
  }
}

WhatsApp Message Info:



use \App\Services\NusaSms;

return response()->json(NusaSms::waGetMessageInfo("78391643125660"));

Success response example:

{
  "error": false,
  "error_code": 0,
  "message": "Message data",
  "data": {
    "destination": "6281212341234",
    "sender": "6281243214321",
    "is_group": false,
    "create_date": "2022-01-28T23:31:50",
    "sent_date": "2022-01-28T23:31:51",
    "read_date": null,
    "delivered_date": "2022-01-28T23:31:52",
    "ref_no": "008078391643125660",
    "status": "D",
    "message": "Hello, world!",
    "caption": null,
    "media_url": null
  }
}
You might also like...
📲 SmsOffice.ge service with notification channel for Laravel
📲 SmsOffice.ge service with notification channel for Laravel

Laravel SmsOffice This package allows you to send SMS messages with SmsOffice.ge API You can send sms with notification class or directly with SmsOffi

Service manager for Slim compatible with Laravel packages

SlimServices SlimServices is a service manager for the Slim PHP microframework based on Laravel 4 service providers and DI container, allowing you to

Generate and autoload custom Helpers, Builder Scope, Service class, Trait

laravel-make-extender Generate and autoload custom helpers, It can generate multilevel helpers in the context of the directory. Generate Service class

Adds a service worker to Magento2 to enable PWA features
Adds a service worker to Magento2 to enable PWA features

Monsoon PWA Adds icons, a web manifest file and a service-worker file to make magento 2 a PWA. Main Features Supports Magento Blank and Luma as well a

A simple artisanal command framework for creating service layer classes

Introdução Este projeto tem como objetivo fornecer alguns comandos adicionais à interface de linha de comando do Laravel para manipular a estrutura da

PHP client library for reCAPTCHA, a free service to protect your website from spam and abuse.

reCAPTCHA PHP client library reCAPTCHA is a free CAPTCHA service that protects websites from spam and abuse. This is a PHP library that wraps up the s

Email validation service in PHP

Email validation service Email validation service in PHP using Laravel 8. Validation features Domain Regular Expression Smtp Txt records Installing de

Ebansos (Electronic Social Assistance) is a web application that provides citizen data management who will receive social assistance to avoid misdirection assistance from public service/government.

E Bansos Ebansos (Electronic Social Assistance) is a web application that provides citizen data management who will receive social assistance to avoid

A bring-your-own-email-first newsletter service. ✨

Typewrite Typewrite a hosted bring-your-own-email newsletter service for people who need a simplistic and privacy-first newsletter service. The core a

Owner
Aghits Nidallah
Hello o/
Aghits Nidallah
Laravel SMS Gateway

This is a Laravel Package for SMS Gateway Integration. Now Sending SMS is easy.

Fowitech 12 Sep 6, 2022
A simple Laravel service provider for easily using HTMLPurifier inside Laravel

HTMLPurifier for Laravel 5/6/7/8 A simple Laravel service provider for easily using HTMLPurifier inside Laravel. From their website: HTML Purifier is

MeWebStudio - Muharrem ERİN 1.7k Jan 6, 2023
MediaDB is a web-based media streaming service written in Laravel and Vue.

MediaDB (API) MediaDB is a web-based media streaming service written in Laravel and Vue. The nginx-vod-module is used for on-the-fly repackaging of MP

François M. 53 Sep 3, 2022
A simple package to manage the creation of a structure composed of the service and repository layers in a Laravel application

Chapolim Este projeto tem como objetivo fornecer alguns comandos adicionais à interface de linha de comando do Laravel, o Artisan, para manipular a es

Eliezer Alves 51 Dec 11, 2022
Laravel 4.* and 5.* service providers to handle PHP errors, dump variables, execute PHP code remotely in Google Chrome

Laravel 4.* service provider for PHP Console See https://github.com/barbushin/php-console-laravel/releases/tag/1.2.1 Use "php-console/laravel-service-

Sergey 73 Jun 1, 2022
Load Laravel service providers based on your application's environment.

Laravel EnvProviders A more finetuned way of managing your service providers in Laravel. This package allows you to configure the environment certain

Sven Luijten 79 Dec 29, 2022
Contextual Service Providers for Laravel

Laravel Context This simple yet powerful package will help you load different Service Providers depending in which context you are. Contexts can be se

Rodrigo Troncoso 51 Dec 25, 2020
Laravel Lumen service provider for Understand.io

The service provider is deprecated - it does not support error grouping. Laravel Lumen service provider for Understand.io You may also be interested i

null 6 May 30, 2019
Project C2 (Laravel 8.x) - Pemograman Web Service (Semester 5)

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Shaynendra Dika Destyawan 0 Dec 26, 2021
Dedicated laravel package for Behpadakht Mellat bank payment service.

Iranian Mellat bank full online payment service Dedicated laravel package for Behpadakht Mellat bank payment service. Features Event calls Log on chan

Mahdi Jedari 5 Apr 19, 2022