Skip to content

Docs ‐ Response

Isaac Sai edited this page Jan 20, 2024 · 1 revision

Introduction to response

Various USSD providers have different APIs to communicate with them. Responses provider you with the flexibility to write your application without worry about the response as part of the core of your application.

Creating response

php artisan ussd:response AfricasTalkingResponse

Construct the response your provider is expecting.

<?php

namespace App\Ussd\Responses;

use Sparors\Ussd\Contracts\Response;

class AfricasTalkingResponse implements Response
{
    public function respond(string $message, bool $terminating): mixed
    {
        return response(
            ($terminating ? 'END' : 'CON') . ' ' . $message,
            200,
            ['Content-Type' => 'text/plain']
        );
    }
}