laravel send sms with textlocal


for the best i skipped step install laravel . you can check laravel.com for installation Documentation.

Step 0 : we register Text Local for using sms for free by sign up with thist link : txtlocal.co.uk you need api-key for action

Step 1 : we download text-local php class from this link : Download . extract file and get textlocal.class.php to project/app/Http/Controllers/ and edit code like below :

<?php

// This is class file of text-local api

namespace App\Http\Controllers;

class Textlocal
{
  ...
}

Step 2 :  in our controller we use code like below : 

<?php

namespace App\Http\Controllers;


use Illuminate\Http\Request;

use App\Http\Controllers\Controller;

use App\Http\Controllers\Textlocal;

class HomeController extends Controller

{

  public function send(){
    $Textlocal = new Textlocal(false, false, 'your apiKey');
 
	$numbers = array(447123456789); // example number you want to send to
	$sender = 'your name';
	$message = 'This is your message';
 
	$response = $Textlocal->sendSms($numbers, $message, $sender);
	return $response;
  }

  public function getInbox(){
    $Textlocal = new Textlocal(false, false, 'your apiKey');
	
	$response = $Textlocal->getInboxes();
	return $response;
  }

  public function getmessages(){
    $Textlocal = new Textlocal(false, false, 'your apiKey');
	
	$inbox_id = '1234';
	
	$response = $Textlocal->getMessages($inbox_id);

    return $response;
  }
}

done ! you can view as want and test right away !

Reference : text-local Doc

Share this Post:

Related Posts:

www.000webhost.com