Skip to content

saber13812002/laravel-linkmobility

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Linkmobility Package for Laravel

Latest Stable Version Latest Unstable Version License Total Downloads

Introduction

This is a simple Laravel Service Provider providing access to the Linkmobility API

Installation

To install the PHP client library using Composer:

composer require jcsofts/laravel-linkmobility

Alternatively, add these two lines to your composer require section:

{
    "require": {
        "jcsofts/laravel-linkmobility": "^1.0"
    }
}

Laravel 5.5+

If you're using Laravel 5.5 or above, the package will automatically register the Linkmobility provider and facade.

Laravel 5.4 and below

Add Jcsofts\LaravelLinkmobility\LinkmobilityServiceProvider to the providers array in your config/app.php:

'providers' => [
    // Other service providers...

    Jcsofts\LaravelLinkmobility\LinkmobilityServiceProvider::class,
],

If you want to use the facade interface, you can use the facade class when needed:

use Jcsofts\LaravelLinkmobility\Facade\Linkmobility;

Or add an alias in your config/app.php:

'aliases' => [
    ...
    'Linkmobility' => Jcsofts\LaravelLinkmobility\Facade\Linkmobility::class,
],

Using Laravel-Linkmobility with Lumen

laravel-linkmobility works with Lumen too! You'll need to do a little work by hand to get it up and running. First, install the package using composer:

composer require jcsofts/laravel-linkmobility

Next, we have to tell Lumen that our library exists. Update bootstrap/app.php and register the LinkmobilityServiceProvider:

$app->register(Jcsofts\LaravelLinkmobility\LinkmobilityServiceProvider::class);

Finally, we need to configure the library. Unfortunately Lumen doesn't support auto-publishing files so you'll have to create the config file yourself by creating a config directory and copying the config file out of the package in to your project:

mkdir config
cp vendor/jcsofts/laravel-linkmobility/config/linkmobility.php config/linkmobility.php

Configuration

You can use artisan vendor:publish to copy the distribution configuration file to your app's config directory:

php artisan vendor:publish

Then update config/linkmobility.php with your credentials. Alternatively, you can update your .env file with the following:

LINKMOBILITY_USERNAME=
LINKMOBILITY_PASSWORD=
LINKMOBILITY_PLATFORM_ID=
LINKMOBILITY_PARTNER_ID=
LINKMOBILITY_USE_DELIVERY_REPORT=true
LINKMOBILITY_DEBUG=true

Usage

To use the Linkmobility Client Library you can use the facade, or request the instance from the service container:

try{
        $messageId=Linkmobility::send('Hello word', '+8618903859xxx');
        echo $messageId;
    }catch(Exception $e){
        echo $e->getMessage();
    }

Or

$linkmobility = app('Linkmobility');

$messageId=$linkmobility->send('Hello word', '+8618903859xxx');