<?php
//PHP - cURL
$ch = curl_init();
$url = "https://api.smsgatewayapi.com/v1/optouts";
$client_id = "XXX"; // Your API client ID (required)
$client_secret = "YYY"; // Your API client secret (required)
$data = [
'number' => "11231231234" //Contact number (required)
];
curl_setopt($ch, CURLOPT_URL, "$url");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-Client-Id: $client_id",
"X-Client-Secret: $client_secret",
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
?>
//NodeJs - HTTP request
const https = require("https");
const client_id = "XXX"; // Your API client ID (required)
const client_secret = "YYY"; // Your API client secret (required)
const data = JSON.stringify({
number: '11231231234' //Contact number (required)
});
const options = {
hostname: "api.smsgatewayapi.com",
port: 443,
path: "/v1/optouts",
method: "POST",
headers: {
"X-Client-Id": client_id,
"X-Client-Secret": client_secret,
"Content-Type": "application/json",
"Content-Length": data.length,
},
};
const req = https.request(options, (res) => {
console.log(`statusCode: ${res.statusCode}`);
res.on("data", (d) => {
process.stdout.write(d);
});
});
req.write(data);
req.end();
//Ruby - Net::HTTP
require "uri"
require "net/http"
url = URI("https://api.smsgatewayapi.com/v1/optouts")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Client-Id"] = "XXX" // Your API key
request["X-Client-Secret"] = "YYY" // Your API secret
request["Content-Type"] = "application/json"
form_data = [
['number', "11231231234] //Contact number (required)
]
request.set_form form_data, 'multipart/form-data'
response = https.request(request)
puts response.read_body
//Python - Requests
import requests
url = "https://api.smsgatewayapi.com/v1/optouts"
payload={
'number' : "11231231234" //Contact number (required)
}
headers = {
'X-Client-Id': 'XXX', #Your API key
'X-Client-Secret': 'YYY', #Your API secret
'Content-Type': 'application/json'
}
response = requests.request(
"POST",
url,
headers=headers,
json=payload
)
print(response.text)
//PowerShell - RestMethod
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("X-Client-Id", "XXX") // Your API key
$headers.Add("X-Client-Secret", "YYY") // Your API secret
$body = '{
"number": "11231231234" //Contact number (required)
}'
$response = Invoke-RestMethod 'https://api.smsgatewayapi.com/v1/optouts' -Method 'POST' -Headers $headers -Body $body -ContentType “application/json; charset=utf-8”
$response | ConvertTo-Json
//Shell - wget
wget --no-check-certificate --quiet \
--method POST \
--timeout=0 \
--header 'X-Client-Id: XXX' \ // Your API key
--header 'X-Client-Secret: YYY' \ // Your API secret
--header 'Content-Type: application/json' \
--body-data '{
"number" : "11231231234" //Contact number (required)
}' \
'https://api.smsgatewayapi.com/v1/optouts'