PHP code example of norris1z / hubtel-ussd

1. Go to this page and download the library: Download norris1z/hubtel-ussd 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/ */

    

norris1z / hubtel-ussd example snippets


    $response = Response::createInstance('Hello Hubtel, i want a response',RequestTypes::RESPONSE);
    $response = Response::createInstance('Hello Hubtel, end the sequence',RequestTypes::RELEASE);

     USSD::process(/** An instance of Hubtel\USSD\Request **/,[
        new Sequence1(),
        new Sequence2(),
        new Sequence3()
    ])->toArray();

    //Sequence1.php
    use Hubtel\USSD\Request;
    use Hubtel\USSD\RequestTypes;
    use Hubtel\USSD\Response;
    use Hubtel\USSD\SequenceInterface;

    class Sequence1 implements SequenceInterface
    {

        public function handle(Request $request)
        {
            return Response::createInstance('Welcome to Freebie Service.\n1. Free Food\n2. Free Drink\n3. Free Airtime',RequestTypes::RESPONSE);
        }
    }