Copy to Clipboard CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS");
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"From\": \"{SenderId}\",\"To\": \"{CommaSeparatedContacts}\", \"Msg\": \"{MessageBody}\", \"SendAt\": \"{OptionScheduleTime}\"}");
CURLcode ret = curl_easy_perform(hnd);
Copy to Clipboard var client = new RestClient("http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS");
var request = new RestRequest(Method.POST);
request.AddParameter("undefined", "{\"From\": \"{SenderId}\",\"To\": \"{CommaSeparatedContacts}\", \"Msg\": \"{MessageBody}\", \"SendAt\": \"{OptionScheduleTime}\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Copy to Clipboard package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS"
payload := strings.NewReader("{\"From\": \"{SenderId}\",\"To\": \"{CommaSeparatedContacts}\", \"Msg\": \"{MessageBody}\", \"SendAt\": \"{OptionScheduleTime}\"}")
req, _ := http.NewRequest("POST", url, payload)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Copy to Clipboard OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"From\": \"{SenderId}\",\"To\": \"{CommaSeparatedContacts}\", \"Msg\": \"{MessageBody}\", \"SendAt\": \"{OptionScheduleTime}\"}");
Request request = new Request.Builder()
.url("http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS")
.post(body)
.build();
Response response = client.newCall(request).execute();
Copy to Clipboard HttpResponse<String> response = Unirest.post("http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS")
.body("{\"From\": \"{SenderId}\",\"To\": \"{CommaSeparatedContacts}\", \"Msg\": \"{MessageBody}\", \"SendAt\": \"{OptionScheduleTime}\"}")
.asString();
Copy to Clipboard var settings = {
"async": true,
"crossDomain": true,
"url": "http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS",
"method": "POST",
"headers": {},
"processData": false,
"data": "{\"From\": \"{SenderId}\",\"To\": \"{CommaSeparatedContacts}\", \"Msg\": \"{MessageBody}\", \"SendAt\": \"{OptionScheduleTime}\"}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Copy to Clipboard var data = JSON.stringify({
"From": "{SenderId}",
"To": "{CommaSeparatedContacts}",
"Msg": "{MessageBody}",
"SendAt": "{OptionScheduleTime}"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS");
xhr.send(data);
Copy to Clipboard var http = require("http");
var options = {
"method": "POST",
"hostname": "2factor.in",
"port": null,
"path": "/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS",
"headers": {}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ From: '{SenderId}',
To: '{CommaSeparatedContacts}',
Msg: '{MessageBody}',
SendAt: '{OptionScheduleTime}' }));
req.end();
Copy to Clipboard var request = require("request");
var options = { method: 'POST',
url: 'http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS',
body:
{ From: '{SenderId}',
To: '{CommaSeparatedContacts}',
Msg: '{MessageBody}',
SendAt: '{OptionScheduleTime}' },
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Copy to Clipboard var unirest = require("unirest");
var req = unirest("POST", "http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS");
req.type("json");
req.send({
"From": "{SenderId}",
"To": "{CommaSeparatedContacts}",
"Msg": "{MessageBody}",
"SendAt": "{OptionScheduleTime}"
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
Copy to Clipboard #import <Foundation/Foundation.h>
NSDictionary *parameters = @{ @"From": @"{SenderId}",
@"To": @"{CommaSeparatedContacts}",
@"Msg": @"{MessageBody}",
@"SendAt": @"{OptionScheduleTime}" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
Copy to Clipboard open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS" in
let body = Cohttp_lwt_body.of_string "{\"From\": \"{SenderId}\",\"To\": \"{CommaSeparatedContacts}\", \"Msg\": \"{MessageBody}\", \"SendAt\": \"{OptionScheduleTime}\"}" in
Client.call ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
Copy to Clipboard <?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"From\": \"{SenderId}\",\"To\": \"{CommaSeparatedContacts}\", \"Msg\": \"{MessageBody}\", \"SendAt\": \"{OptionScheduleTime}\"}",
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Copy to Clipboard <?php
$request = new HttpRequest();
$request->setUrl('http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS');
$request->setMethod(HTTP_METH_POST);
$request->setBody('{"From": "{SenderId}","To": "{CommaSeparatedContacts}", "Msg": "{MessageBody}", "SendAt": "{OptionScheduleTime}"}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Copy to Clipboard <?php
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append('{"From": "{SenderId}","To": "{CommaSeparatedContacts}", "Msg": "{MessageBody}", "SendAt": "{OptionScheduleTime}"}');
$request->setRequestUrl('http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS');
$request->setRequestMethod('POST');
$request->setBody($body);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Copy to Clipboard import http.client
conn = http.client.HTTPConnection("2factor.in")
payload = "{\"From\": \"{SenderId}\",\"To\": \"{CommaSeparatedContacts}\", \"Msg\": \"{MessageBody}\", \"SendAt\": \"{OptionScheduleTime}\"}"
conn.request("POST", "/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS", payload)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Copy to Clipboard import requests
url = "http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS"
payload = "{\"From\": \"{SenderId}\",\"To\": \"{CommaSeparatedContacts}\", \"Msg\": \"{MessageBody}\", \"SendAt\": \"{OptionScheduleTime}\"}"
response = requests.request("POST", url, data=payload)
print(response.text)
Copy to Clipboard require 'uri'
require 'net/http'
url = URI("http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request.body = "{\"From\": \"{SenderId}\",\"To\": \"{CommaSeparatedContacts}\", \"Msg\": \"{MessageBody}\", \"SendAt\": \"{OptionScheduleTime}\"}"
response = http.request(request)
puts response.read_body
Copy to Clipboard curl --request POST \
--url http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS \
--data '{"From": "{SenderId}","To": "{CommaSeparatedContacts}", "Msg": "{MessageBody}", "SendAt": "{OptionScheduleTime}"}'
Copy to Clipboard echo '{"From": "{SenderId}","To": "{CommaSeparatedContacts}", "Msg": "{MessageBody}", "SendAt": "{OptionScheduleTime}"}' | \
http POST http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS
Copy to Clipboard wget --quiet \
--method POST \
--body-data '{"From": "{SenderId}","To": "{CommaSeparatedContacts}", "Msg": "{MessageBody}", "SendAt": "{OptionScheduleTime}"}' \
--output-document \
- http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS
Copy to Clipboard import Foundation
let parameters = [
"From": "{SenderId}",
"To": "{CommaSeparatedContacts}",
"Msg": "{MessageBody}",
"SendAt": "{OptionScheduleTime}"
]
let postData = NSJSONSerialization.dataWithJSONObject(parameters, options: nil, error: nil)
var request = NSMutableURLRequest(URL: NSURL(string: "http://2factor.in/API/V1/{api_key}/ADDON_SERVICES/SEND/TSMS")!,
cachePolicy: .UseProtocolCachePolicy,
timeoutInterval: 10.0)
request.HTTPMethod = "POST"
request.HTTPBody = postData
let session = NSURLSession.sharedSession()
let dataTask = session.dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
println(error)
} else {
let httpResponse = response as? NSHTTPURLResponse
println(httpResponse)
}
})
dataTask.resume()