PHP code example of m-shule / africastalking

1. Go to this page and download the library: Download m-shule/africastalking library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

m-shule / africastalking example snippets


// config/app.php
'providers' => [
    ...
    MShule\AfricasTalking\AfricasTalkingServiceProvider::class,
],

// config/services.php
...
'africastalking' => [
    'api_key' => env('AFRICASTALKING_API_KEY'),
    'username' => env('AFRICASTALKING_USERNAME'),
    'from' => env('AFRICASTALKING_FROM'),
],
...

// .env
...
AFRICASTALKING_API_KEY=
AFRICASTALKING_USERNAME=
AFRICASTALKING_FROM=
...
 php


// app/Notifications/VpsServerOrdered.php

namespace App\Notifications;

use Illuminate\Notifications\Notification;
use MShule\AfricasTalking\AfricasTalkingChannel;
use MShule\AfricasTalking\AfricasTalkingMessage;

class VpsServerOrdered extends Notification
{
    public function via($notifiable)
    {
        return [AfricasTalkingChannel::class];
    }

    public function toAfricasTalking($notifiable)
    {
    	return (new AfricasTalkingMessage())->content("Your service was ordered!");
    }
}
 php
return (new AfricasTalkingMessage())->content("Your service was ordered!")->from('60606');