This document provides information on how to use the USSD API provided by [Your Company/Service]. The USSD API allows you to interact with our service using USSD codes.
The USSD API endpoint is:
https://yourdomain.com
The following parameters are required to make requests to the USSD API:
SESSIONID
: The session ID for the USSD session.USSDCODE
: The USSD code associated with your service.NETWORK
: The mobile network associated with the user (e.g., "saf" for Safaricom).MSISDN
: The phone number of the user making the USSD request.INPUT
: The user's input during the USSD session.
<?php$url = "https://yourdomain.com";$params = ['SESSIONID' => '123456789','USSDCODE' => '*123#','NETWORK' => 'saf','MSISDN' => '+1234567890','INPUT' => '1',];// Build the URL with parameters$requestUrl = $url . '?' . http_build_query($params);// Initialize cURL session$ch = curl_init($requestUrl);// Set cURL optionscurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);// Execute cURL session and get the response$response = curl_exec($ch);// Close cURL sessioncurl_close($ch);// Output the responseecho $response;?>
import requestsurl = "https://yourdomain.com"params = {'SESSIONID': '123456789','USSDCODE': '*123#','NETWORK': 'saf','MSISDN': '+1234567890','INPUT': '1',}# Make GET request using requests libraryresponse = requests.get(url, params=params)# Output the responseprint(response.text)
const axios = require('axios');const url = "https://yourdomain.com";const params = {SESSIONID: '123456789',USSDCODE: '*123#',NETWORK: 'saf',MSISDN: '+1234567890',INPUT: '1',};// Make GET request using axios libraryaxios.get(url, { params }).then(response => {// Output the responseconsole.log(response.data);}).catch(error => {console.error(error);});
Make sure to install the required libraries (requests for Python and axios for Node.js) using the respective package managers before running the code.