To help you get started with the iWantFuel API quickly and confidently, we’ve created plug-and-play code samples across all major programming languages and libraries.
Whether you're building in PHP, Python, JavaScript, Java, or beyond, these examples are designed to simplify your development process.
At iWantFuel, our mission is to help you unlock the full power of our platform—while keeping integration seamless, secure, and developer-friendly.
Available Code Samples Include:
- C# – HttpClient, RestSharp
- cURL
- Dart – dio, http
- Go – Native
- HTTP (raw)
- Java – OkHttp, Unirest
- JavaScript – Fetch, jQuery, XHR
- Kotlin – OkHttp
- C – libcurl
- Node.js – Axios, Native, Request, Unirest
- Objective-C – NSURLSession
- OCaml – Cohttp
- PHP – cURL, Guzzle, HTTP_Request2, pecl_http
- PowerShell – Invoke-RestMethod
- Python – http.client, Requests
- R – httr, RCurl
- Ruby – Net::HTTP, reqwest, Httpie
- Shell – wget
- Swift – URLSession
Start integrating with confidence—and bring seamless driver management to your platform today.
Body
{
"Mobile_Number": "711234972",
"dialing_code": "27",
"int_num": "27711234972",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
}
Response
{
"success": true,
"message": "SMS sent",
"to": "27711234972",
"provider_status": "200",
"provider_body": {
"cost": 1,
"remainingBalance": 10079,
"eventId": 15612196983,
"sample": "Hello from iWantFuel SMS API!",
"costBreakdown": [
{
"quantity": 1,
"cost": 1,
"network": "Local"
}
],
"messages": 1,
"parts": 1,
"errorReport": {
"noNetwork": 0,
"noContents": 0,
"contentToLong": 0,
"duplicates": 0,
"optedOuts": 0,
"faults": []
}
}
}✅ Insert OK, new id: 111690
C# - HttpClient
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://www.iwantfuel.tech/api/send-sms-endpoint.php");
request.Headers.Add("X-API-KEY", "API KEY HERE");
request.Headers.Add("X-SECRET-KEY", "SECRET KEY HERE");
var content = new StringContent("{\n \"Mobile_Number\": \"711234567\",\n \"dialing_code\": \"27\",\n \"int_num\": \"27711234567\",\n \"message\": \"Hello from iWantFuel SMS API!\",\n \"ref_no\": \"SMD432\"\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
C# - RestSharp
var options = new RestClientOptions("https://www.iwantfuel.tech")
{
MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/api/send-sms-endpoint.php", Method.Post);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-API-KEY", "API KEY HERE");
request.AddHeader("X-SECRET-KEY", "SECRET KEY HERE");
var body = @"{" + "\n" +
@" ""Mobile_Number"": ""711234567""," + "\n" +
@" ""dialing_code"": ""27""," + "\n" +
@" ""int_num"": ""27711234567""," + "\n" +
@" ""message"": ""Hello from iWantFuel SMS API!""," + "\n" +
@" ""ref_no"": ""SMD432""" + "\n" +
@"}";
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
cURL
curl --location 'https://www.iwantfuel.tech/api/send-sms-endpoint.php' \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: API KEY HERE' \
--header 'X-SECRET-KEY: SECRET KEY HERE' \
--data '{
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
}'
Dart - dio
var headers = {
'Content-Type': 'application/json',
'X-API-KEY': 'API KEY HERE',
'X-SECRET-KEY': 'SECRET KEY HERE'
};
var data = json.encode({
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
});
var dio = Dio();
var response = await dio.request(
'https://www.iwantfuel.tech/api/send-sms-endpoint.php',
options: Options(
method: 'POST',
headers: headers,
),
data: data,
);
if (response.statusCode == 200) {
print(json.encode(response.data));
}
else {
print(response.statusMessage);
}
Dart - http
var headers = {
'Content-Type': 'application/json',
'X-API-KEY': 'API KEY HERE',
'X-SECRET-KEY': 'SECRET KEY HERE'
};
var request = http.Request('POST', Uri.parse('https://www.iwantfuel.tech/api/send-sms-endpoint.php'));
request.body = json.encode({
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
});
request.headers.addAll(headers);
http.StreamedResponse response = await request.send();
if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}
Go - Native
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.iwantfuel.tech/api/send-sms-endpoint.php"
method := "POST"
payload := strings.NewReader(`{
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-API-KEY", "API KEY HERE")
req.Header.Add("X-SECRET-KEY", "SECRET KEY HERE")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
HTTP
POST /api/send-sms-endpoint.php HTTP/1.1
Host: www.iwantfuel.tech
Content-Type: application/json
X-API-KEY: API KEY HERE
X-SECRET-KEY: SECRET KEY HERE
Content-Length: 154
{
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
}
Java - OkHttp
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"Mobile_Number\": \"711234567\",\n \"dialing_code\": \"27\",\n \"int_num\": \"27711234567\",\n \"message\": \"Hello from iWantFuel SMS API!\",\n \"ref_no\": \"SMD432\"\n}");
Request request = new Request.Builder()
.url("https://www.iwantfuel.tech/api/send-sms-endpoint.php")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("X-API-KEY", "API KEY HERE")
.addHeader("X-SECRET-KEY", "SECRET KEY HERE")
.build();
Response response = client.newCall(request).execute();
Java - Unirest
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://www.iwantfuel.tech/api/send-sms-endpoint.php")
.header("Content-Type", "application/json")
.header("X-API-KEY", "API KEY HERE")
.header("X-SECRET-KEY", "SECRET KEY HERE")
.body("{\n \"Mobile_Number\": \"711234567\",\n \"dialing_code\": \"27\",\n \"int_num\": \"27711234567\",\n \"message\": \"Hello from iWantFuel SMS API!\",\n \"ref_no\": \"SMD432\"\n}")
.asString();
JavaScript - Fetch
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("X-API-KEY", "API KEY HERE");
myHeaders.append("X-SECRET-KEY", "SECRET KEY HERE");
const raw = JSON.stringify({
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
});
const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("https://www.iwantfuel.tech/api/send-sms-endpoint.php", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
JavaScript - jQuery
var settings = {
"url": "https://www.iwantfuel.tech/api/send-sms-endpoint.php",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"X-API-KEY": "API KEY HERE",
"X-SECRET-KEY": "SECRET KEY HERE"
},
"data": JSON.stringify({
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
JavaScript - XHR
// WARNING: For POST requests, body is set to null by browsers.
var data = JSON.stringify({
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://www.iwantfuel.tech/api/send-sms-endpoint.php");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("X-API-KEY", "API KEY HERE");
xhr.setRequestHeader("X-SECRET-KEY", "SECRET KEY HERE");
xhr.send(data);
Kotlin - Okhttp
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://www.iwantfuel.tech/api/send-sms-endpoint.php");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "X-API-KEY: API KEY HERE");
headers = curl_slist_append(headers, "X-SECRET-KEY: SECRET KEY HERE");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *data = "{\n \"Mobile_Number\": \"711234567\",\n \"dialing_code\": \"27\",\n \"int_num\": \"27711234567\",\n \"message\": \"Hello from iWantFuel SMS API!\",\n \"ref_no\": \"SMD432\"\n}";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
res = curl_easy_perform(curl);
curl_slist_free_all(headers);
}
curl_easy_cleanup(curl);
C - libcurl
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://www.iwantfuel.tech/api/add_driver.php");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "X-API-Key: Enter Your API Key Here");
headers = curl_slist_append(headers, "X-Secret-Key: Enter Your Secret Key Here");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *data = "{\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"Mobile_Number\": \"0821234567\",\n \"dialing_code\": \"+27\",\n \"int_num\": \"+27\",\n \"active\": \"Yes\"\n}";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
res = curl_easy_perform(curl);
curl_slist_free_all(headers);
}
curl_easy_cleanup(curl);
NodeJs - Axios
const axios = require('axios');
let data = JSON.stringify({
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://www.iwantfuel.tech/api/send-sms-endpoint.php',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': 'API KEY HERE',
'X-SECRET-KEY': 'SECRET KEY HERE'
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
NodeJs - Native
var https = require('follow-redirects').https;
var fs = require('fs');
var options = {
'method': 'POST',
'hostname': 'www.iwantfuel.tech',
'path': '/api/send-sms-endpoint.php',
'headers': {
'Content-Type': 'application/json',
'X-API-KEY': 'API KEY HERE',
'X-SECRET-KEY': 'SECRET KEY HERE'
},
'maxRedirects': 20
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = JSON.stringify({
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
});
req.write(postData);
req.end();
NodeJs - Request
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://www.iwantfuel.tech/api/send-sms-endpoint.php',
'headers': {
'Content-Type': 'application/json',
'X-API-KEY': 'API KEY HERE',
'X-SECRET-KEY': 'SECRET KEY HERE'
},
body: JSON.stringify({
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
NodeJs - Unirest
var unirest = require('unirest');
var req = unirest('POST', 'https://www.iwantfuel.tech/api/send-sms-endpoint.php')
.headers({
'Content-Type': 'application/json',
'X-API-KEY': 'API KEY HERE',
'X-SECRET-KEY': 'SECRET KEY HERE'
})
.send(JSON.stringify({
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
}))
.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.raw_body);
});
Objective-C - NSURLSession
#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://www.iwantfuel.tech/api/send-sms-endpoint.php"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Content-Type": @"application/json",
@"X-API-KEY": @"API KEY HERE",
@"X-SECRET-KEY": @"SECRET KEY HERE"
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\n \"Mobile_Number\": \"711234567\",\n \"dialing_code\": \"27\",\n \"int_num\": \"27711234567\",\n \"message\": \"Hello from iWantFuel SMS API!\",\n \"ref_no\": \"SMD432\"\n}" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
dispatch_semaphore_signal(sema);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
OCaml - Cohttp
open Lwt
open Cohttp
open Cohttp_lwt_unix
let postData = ref "{\n \"Mobile_Number\": \"711234567\",\n \"dialing_code\": \"27\",\n \"int_num\": \"27711234567\",\n \"message\": \"Hello from iWantFuel SMS API!\",\n \"ref_no\": \"SMD432\"\n}";;
let reqBody =
let uri = Uri.of_string "https://www.iwantfuel.tech/api/send-sms-endpoint.php" in
let headers = Header.init ()
|> fun h -> Header.add h "Content-Type" "application/json"
|> fun h -> Header.add h "X-API-KEY" "API KEY HERE"
|> fun h -> Header.add h "X-SECRET-KEY" "SECRET KEY HERE"
in
let body = Cohttp_lwt.Body.of_string !postData in
Client.call ~headers ~body `POST uri >>= fun (_resp, body) ->
body |> Cohttp_lwt.Body.to_string >|= fun body -> body
let () =
let respBody = Lwt_main.run reqBody in
print_endline (respBody)
PHP - cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://www.iwantfuel.tech/api/send-sms-endpoint.php',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-API-KEY: API KEY HERE',
'X-SECRET-KEY: SECRET KEY HERE'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
PHP - Guzzle
<?php
$client = new Client();
$headers = [
'Content-Type' => 'application/json',
'X-API-KEY' => 'API KEY HERE',
'X-SECRET-KEY' => 'SECRET KEY HERE'
];
$body = '{
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
}';
$request = new Request('POST', 'https://www.iwantfuel.tech/api/send-sms-endpoint.php', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
PHP - HTTP_Request2
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://www.iwantfuel.tech/api/send-sms-endpoint.php');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Content-Type' => 'application/json',
'X-API-KEY' => 'API KEY HERE',
'X-SECRET-KEY' => 'SECRET KEY HERE'
));
$request->setBody('{\n "Mobile_Number": "711234567",\n "dialing_code": "27",\n "int_num": "27711234567",\n "message": "Hello from iWantFuel SMS API!",\n "ref_no": "SMD432"\n}');
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
PHP - pecl_http
<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://www.iwantfuel.tech/api/send-sms-endpoint.php');
$request->setRequestMethod('POST');
$body = new http\Message\Body;
$body->append('{
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
}');
$request->setBody($body);
$request->setOptions(array());
$request->setHeaders(array(
'Content-Type' => 'application/json',
'X-API-KEY' => 'API KEY HERE',
'X-SECRET-KEY' => 'SECRET KEY HERE'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
PowerShell - RestMethod
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("X-API-KEY", "API KEY HERE")
$headers.Add("X-SECRET-KEY", "SECRET KEY HERE")
$body = @"
{
`"Mobile_Number`": `"711234567`",
`"dialing_code`": `"27`",
`"int_num`": `"27711234567`",
`"message`": `"Hello from iWantFuel SMS API!`",
`"ref_no`": `"SMD432`"
}
"@
$response = Invoke-RestMethod 'https://www.iwantfuel.tech/api/send-sms-endpoint.php' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
Python - http.client
import http.client
import json
conn = http.client.HTTPSConnection("www.iwantfuel.tech")
payload = json.dumps({
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
})
headers = {
'Content-Type': 'application/json',
'X-API-KEY': 'API KEY HERE',
'X-SECRET-KEY': 'SECRET KEY HERE'
}
conn.request("POST", "/api/send-sms-endpoint.php", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Python - Requests
import requests
import json
url = "https://www.iwantfuel.tech/api/send-sms-endpoint.php"
payload = json.dumps({
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
})
headers = {
'Content-Type': 'application/json',
'X-API-KEY': 'API KEY HERE',
'X-SECRET-KEY': 'SECRET KEY HERE'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
R - httr
library(httr)
headers = c(
'Content-Type' = 'application/json',
'X-API-KEY' = 'API KEY HERE',
'X-SECRET-KEY' = 'SECRET KEY HERE'
)
body = '{
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
}';
res <- VERB("POST", url = "https://www.iwantfuel.tech/api/send-sms-endpoint.php", body = body, add_headers(headers))
cat(content(res, 'text'))
R - RCurl
library(RCurl)
headers = c(
"Content-Type" = "application/json",
"X-API-KEY" = "API KEY HERE",
"X-SECRET-KEY" = "SECRET KEY HERE"
)
params = "{
\"Mobile_Number\": \"711234567\",
\"dialing_code\": \"27\",
\"int_num\": \"27711234567\",
\"message\": \"Hello from iWantFuel SMS API!\",
\"ref_no\": \"SMD432\"
}"
res <- postForm("https://www.iwantfuel.tech/api/send-sms-endpoint.php", .opts=list(postfields = params, httpheader = headers, followlocation = TRUE), style = "httppost")
cat(res)
Ruby - Net::HTTP
require "uri"
require "json"
require "net/http"
url = URI("https://www.iwantfuel.tech/api/send-sms-endpoint.php")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["X-API-KEY"] = "API KEY HERE"
request["X-SECRET-KEY"] = "SECRET KEY HERE"
request.body = JSON.dump({
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API\!",
"ref_no": "SMD432"
})
response = https.request(request)
puts response.read_body
Ruby - reqwest
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::builder()
.build()?;
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("Content-Type", "application/json".parse()?);
headers.insert("X-API-KEY", "API KEY HERE".parse()?);
headers.insert("X-SECRET-KEY", "SECRET KEY HERE".parse()?);
let data = r#"{
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
}"#;
let json: serde_json::Value = serde_json::from_str(&data)?;
let request = client.request(reqwest::Method::POST, "https://www.iwantfuel.tech/api/send-sms-endpoint.php")
.headers(headers)
.json(&json);
let response = request.send().await?;
let body = response.text().await?;
println!("{}", body);
Ok(())
}
Ruby - Httpie
require "uri"
require "json"
require "net/http"
url = URI("https://www.iwantfuel.tech/api/send-sms-endpoint.php")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["X-API-KEY"] = "API KEY HERE"
request["X-SECRET-KEY"] = "SECRET KEY HERE"
request.body = JSON.dump({
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API\!",
"ref_no": "SMD432"
})
response = https.request(request)
puts response.read_body
Shell - wget
wget --no-check-certificate --quiet \
--method POST \
--timeout=0 \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: API KEY HERE' \
--header 'X-SECRET-KEY: SECRET KEY HERE' \
--body-data '{
"Mobile_Number": "711234567",
"dialing_code": "27",
"int_num": "27711234567",
"message": "Hello from iWantFuel SMS API!",
"ref_no": "SMD432"
}' \
'https://www.iwantfuel.tech/api/send-sms-endpoint.php'
Swift - URLSession
let parameters = "{\n \"Mobile_Number\": \"711234567\",\n \"dialing_code\": \"27\",\n \"int_num\": \"27711234567\",\n \"message\": \"Hello from iWantFuel SMS API!\",\n \"ref_no\": \"SMD432\"\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://www.iwantfuel.tech/api/send-sms-endpoint.php")!,timeoutInterval: Double.infinity)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("API KEY HERE", forHTTPHeaderField: "X-API-KEY")
request.addValue("SECRET KEY HERE", forHTTPHeaderField: "X-SECRET-KEY")
request.httpMethod = "POST"
request.httpBody = postData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
}
task.resume()