var client = new HttpClient();
string[] receiver = { "گیرنده ی دوم" , "گیرنده ی اول"};
string[] Message = { "پیام دوم" , "پیام اول"};
var data = new
{
Message = Message,
SenderNumber = "فرستنده",
MobileNumber = receiver,
SendToBlocksNumber=true,
};
var url = "https://api.kavansms.com/api/sendpeertopeersms";
client.DefaultRequestHeaders.Add("ApiKey", "کد دسترسی شما");
var objectStr = JsonConvert.SerializeObject(data);
var content = new StringContent(objectStr, Encoding.UTF8, "application/json");
var response = client.PostAsync(url, content).Result;
string resultContent = await response.Content.ReadAsStringAsync();
return resultContent;
$url ='https://api.kavansms.com/api/sendpeertopeersms';
$receiver = array("گیرنده دوم " , "گیرنده اول");
$post_data = json_encode(array(
'Message' =>array("پیام دوم" , "پیام اول"),
'SenderNumber' => 'فرستنده',
'SendToBlocksNumber' => 'false',
'MobileNumber' => $receiver,
));
$process = curl_init();
curl_setopt( $process,CURLOPT_URL,$url);
curl_setopt( $process, CURLOPT_TIMEOUT,30);
curl_setopt( $process, CURLOPT_POST, 1);
curl_setopt($process, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt( $process, CURLOPT_POSTFIELDS, $post_data);
curl_setopt( $process, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt( $process, CURLOPT_FOLLOWLOCATION, true);
curl_setopt( $process, CURLOPT_HTTPHEADER, array('Content-Type: application/json'
,'ApiKey:کد دسترسی'));
$return = curl_exec( $process);
$httpcode = curl_getinfo( $process, CURLINFO_HTTP_CODE);
curl_close($process);
$decoded = json_decode($return);
print_r($decoded);
const axios = require('axios');
axios.post( 'https://api.kavansms.com/api/sendpeertopeersms', {
"Message": ["پیام اول"],
"SenderNumber": "فرستنده",
"MobileNumber": ["گیرنده اول"] }, {
headers:{
ApiKey: 'کد دسترسی شما'
}}).then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
import requests
url = 'https://api.kavansms.com/api/sendpeertopeersms'
receiver = ["گیرنده ی اول", "گیرنده ی دوم"]
message = ["متن پیام اول", "متن پیام دوم"]
myobj = {'Message' :message,
'SenderNumber' : 'فرستنده',
'MobileNumber' : receiver}
x = requests.post(url, json = myobj, headers = {"ApiKey": "کد دسترسی شما"})
print(x.text)