$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sms.asanak.ir/webservice/v2rest/p2psendsms',
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 =>'{
"username": "required",
"password": "required",
"data": [
{
"source": "string",
"destination": "string",
"message": "string",
"send_to_blacklist": "int"
}
]
}',
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
curl --location 'https://sms.asanak.ir/webservice/v2rest/p2psendsms' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"username": "required",
"password": "required",
"data": [
{
"source": "string",
"destination": "string",
"message": "string",
"send_to_blacklist": "int"
}
]
}'
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://sms.asanak.ir/webservice/v2rest/p2psendsms");
request.Headers.Add("Accept", "application/json");
var content = new StringContent("{\r\n \"username\": \"required\",\r\n \"password\": \"required\",\r\n \"data\": [\r\n {\r\n \"source\": \"\",\r\n \"destination\": \"\",\r\n \"message\": \"\",\r\n \"send_to_blacklist\": \"int\"\r\n }\r\n ]\r\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"username\": \"required\",\r\n \"password\": \"required\",\r\n \"data\": [\r\n {\r\n \"source\": \"\",\r\n \"destination\": \"\",\r\n \"message\": \"\",\r\n \"send_to_blacklist\": \"int\"\r\n }\r\n ]\r\n}");
Request request = new Request.Builder()
.url("https://sms.asanak.ir/webservice/v2rest/p2psendsms")
.method("POST", body)
.addHeader("Accept", "application/json")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
import requests
import json
url = "https://sms.asanak.ir/webservice/v2rest/p2psendsms"
payload = json.dumps({
"username": "required",
"password": "required",
"data": [
{
"source": "",
"destination": "",
"message": "",
"send_to_blacklist": "int"
}
]
})
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://sms.asanak.ir/webservice/v2rest/p2psendsms"
method := "POST"
payload := strings.NewReader(`{`+"
"+`
"username": "required",`+"
"+`
"password": "required",`+"
"+`
"data": [`+"
"+`
{`+"
"+`
"source": "",`+"
"+`
"destination": "",`+"
"+`
"message": "",`+"
"+`
"send_to_blacklist": "int"`+"
"+`
}`+"
"+`
]`+"
"+`
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Accept", "application/json")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
#import
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://sms.asanak.ir/webservice/v2rest/p2psendsms"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Accept": @"application/json",
@"Content-Type": @"application/json"
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\r\n \"username\": \"required\",\r\n \"password\": \"required\",\r\n \"data\": [\r\n {\r\n \"source\": \"\",\r\n \"destination\": \"\",\r\n \"message\": \"\",\r\n \"send_to_blacklist\": \"int\"\r\n }\r\n ]\r\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);
var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"username": "required",
"password": "required",
"data": [
{
"source": "",
"destination": "",
"message": "",
"send_to_blacklist": "int"
}
]
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://sms.asanak.ir/webservice/v2rest/p2psendsms", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
require "uri"
require "json"
require "net/http"
url = URI("https://sms.asanak.ir/webservice/v2rest/p2psendsms")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Accept"] = "application/json"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"username": "required",
"password": "required",
"data": [
{
"source": "",
"destination": "",
"message": "",
"send_to_blacklist": "int"
}
]
})
response = https.request(request)
puts response.read_body
#[tokio::main]
async fn main() -> Result<(), Box> {
let client = reqwest::Client::builder()
.build()?;
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("Content-Type", "application/json".parse()?);
let data = r#"{
"username": "your-username",
"password": "your-password",
"data": [
{
"source": "string",
"destination": "string",
"message": "string",
"send_to_blacklist": "int"
}
]
}"#;
let json: serde_json::Value = serde_json::from_str(&data)?;
let request = client.request(reqwest::Method::POST, "https://sms.asanak.ir/webservice/v2rest/p2psendsms")
.headers(headers)
.json(&json);
let response = request.send().await?;
let body = response.text().await?;
println!("{}", body);
Ok(())
}