تماس دوطرفه
پیشنهاد میشود قبل از مطالعه این مطلب،ابتدا اینجا را بررسی فرمایید.
۱: ایجاد تماس دوطرفه بین دو داخلی 570 و 553
نمونه فراخوانی
- نمونه کد استفاده
- نمونه خروجی
- PHP
- JS
- Curl
نمایش کامل کد PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://192.168.51.20/api/v4/call/originate/act',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS =>'{
"caller":"570",
"callee":"553",
"context":"main_routing",
"caller_id":"masking",
"timeout":"30"
}',
CURLOPT_HTTPHEADER => array(
'X-APIKEY: 9UV0BWKRL83PYIH9Gv1fI85d41lO4S932EeX3wHC47sHjMJOMG',
'Authorization: Basic c2FkcjpTYWRyQDEyMw==',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
نمایش کامل کد JS
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<script>
var settings = {
"url": "http://192.168.51.20/api/v4/call/originate/act",
"method": "PUT",
"timeout": 0,
"headers": {
"X-APIKEY": "9UV0BWKRL83PYIH9Gv1fI85d41lO4S932EeX3wHC47sHjMJOMG",
"Authorization": "Basic c2FkcjpTYWRyQDEyMw==",
"Content-Type": "application/json"
},
"data": JSON.stringify({
"caller": "570",
"callee": "553",
"context": "main_routing",
"caller_id": "masking",
"timeout": "30"
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
</script>
</body>
</html>
نمایش کامل کد Curl
curl --location --request PUT 'http://192.168.51.20/api/v4/call/originate/act' \
--header 'X-APIKEY: 9UV0BWKRL83PYIH9Gv1fI85d41lO4S932EeX3wHC47sHjMJOMG' \
--header 'Authorization: Basic c2FkcjpTYWRyQDEyMw==' \
--header 'Content-Type: application/json' \
--data-raw '{
"caller":"570",
"callee":"553",
"context":"main_routing",
"caller_id":"masking",
"timeout":"30"
}'
{
"success": 1,
"message": null,
"data": {
"originated_call_id": "orig.call.1703145054.787335"
}
}
۲: ایجاد تماس دوطرفه بین شماره 09376131239 و داخلی 521
باتوجه به اینکه مسیر خروجی caller(نفر اول تماس) توسط پارامتر trunk_name
مشخص میشود،وجود این مقدار در سناریو ضروری میباشد.
که در مثال برابر با Cisco میباشد.
نمونه فراخوانی
- نمونه کد استفاده
- نمونه خروجی
- PHP
- JS
- Curl
نمایش کامل کد PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://192.168.51.20/api/v4/call/originate/act',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS =>'{
"caller":"09376131239",
"callee":"521",
"context":"main_routing",
"caller_id":"557",
"trunk_name":"Cisco",
"timeout":"30"
}',
CURLOPT_HTTPHEADER => array(
'X-APIKEY: 9UV0BWKRL83PYIH9Gv1fI85d41lO4S932EeX3wHC47sHjMJOMG',
'Authorization: Basic c2FkcjpTYWRyQDEyMw==',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
نمایش کامل کد JS
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<script>
var settings = {
"url": "http://192.168.51.20/api/v4/call/originate/act",
"method": "PUT",
"timeout": 0,
"headers": {
"X-APIKEY": "9UV0BWKRL83PYIH9Gv1fI85d41lO4S932EeX3wHC47sHjMJOMG",
"Authorization": "Basic c2FkcjpTYWRyQDEyMw==",
"Content-Type": "application/json"
},
"data": JSON.stringify({
"caller": "09376131239",
"callee": "521",
"context": "main_routing",
"caller_id": "557",
"trunk_name": "Cisco",
"timeout": "30"
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
</script>
</body>
</html>
نمایش کامل کد Curl
curl --location --request PUT 'http://192.168.51.20/api/v4/call/originate/act' \
--header 'X-APIKEY: 9UV0BWKRL83PYIH9Gv1fI85d41lO4S932EeX3wHC47sHjMJOMG' \
--header 'Authorization: Basic c2FkcjpTYWRyQDEyMw==' \
--header 'Content-Type: application/json' \
--data-raw '{
"caller":"09376131239",
"callee":"521",
"context":"main_routing",
"caller_id":"557",
"trunk_name":"Cisco",
"timeout":"30"
}'
{
"success": 1,
"message": null,
"data": {
"originated_call_id": "orig.call.1703145054.787335"
}
}
۳: ایجاد تماس بین داخلی 521 و شماره 09376131239
دقت فرمایید باتوجه به اینکه مسیر خروجی calle(نفر دوم تماس) توسط پارامتر context
مشخص میشود پس در صورتی که نفر دوم تماس بر
روی شبکه مخابراتی بود نیاز میباشد context یا بهتر است بگوییم کامپوننت Outgoing Route
مربوط به این context به شبکه مخابراتی
دسترسی داشته باشد،برای انجام این کار کامپوننت Outgoing Route
را به کامپوننت ترانک متصل میکنیم.
در این مثال مقدار context برابر با main_routing قرار داده شده است و در کامپوننت Outgoing_Route نیز مقدار context برابر با main_routing تنظیم شدهاست.بنابراین تماس نفر دوم از این Outgoing Route خارج شده که به ترانک نیز دسترسی دارد.
نمونه فراخوانی
- نمونه کد استفاده
- نمونه خروجی
- PHP
- JS
- Curl
نمایش کامل کد PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://192.168.51.20/api/v4/call/originate/act',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS =>'{
"caller":"521",
"callee":"09376131239",
"context":"main_routing",
"caller_id":"557",
"timeout":"30"
}',
CURLOPT_HTTPHEADER => array(
'X-APIKEY: 9UV0BWKRL83PYIH9Gv1fI85d41lO4S932EeX3wHC47sHjMJOMG',
'Authorization: Basic c2FkcjpTYWRyQDEyMw==',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
نمایش کامل کد JS
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<script>
var settings = {
"url": "http://192.168.51.20/api/v4/call/originate/act",
"method": "PUT",
"timeout": 0,
"headers": {
"X-APIKEY": "9UV0BWKRL83PYIH9Gv1fI85d41lO4S932EeX3wHC47sHjMJOMG",
"Authorization": "Basic c2FkcjpTYWRyQDEyMw==",
"Content-Type": "application/json"
},
"data": JSON.stringify({
"caller": "521",
"callee": "09376131239",
"context": "main_routing",
"caller_id": "557",
"timeout": "30"
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
</script>
</body>
</html>
نمایش کامل کد Curl
curl --location --request PUT 'http://192.168.51.20/api/v4/call/originate/act' \
--header 'X-APIKEY: 9UV0BWKRL83PYIH9Gv1fI85d41lO4S932EeX3wHC47sHjMJOMG' \
--header 'Authorization: Basic c2FkcjpTYWRyQDEyMw==' \
--header 'Content-Type: application/json' \
--data-raw '{
"caller":"521",
"callee":"09376131239",
"context":"main_routing",
"caller_id":"557",
"timeout":"30"
}'
{
"success": 1,
"message": null,
"data": {
"originated_call_id": "orig.call.1703145054.787335"
}
}
۴: ایجاد تماس بین شماره 31041570 و شماره 09376131239
نمونه فراخوانی
- نمونه کد استفاده
- نمونه خروجی
- PHP
- JS
- Curl
نمایش کامل کد PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://192.168.51.20/api/v4/call/originate/act',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS =>'{
"caller":"31041570",
"callee":"09376131239",
"context":"main_routing",
"caller_id":"557",
"trunk_name":"Cisco",
"timeout":"30"
}',
CURLOPT_HTTPHEADER => array(
'X-APIKEY: 9UV0BWKRL83PYIH9Gv1fI85d41lO4S932EeX3wHC47sHjMJOMG',
'Authorization: Basic c2FkcjpTYWRyQDEyMw==',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
نمایش کامل کد JS
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<script>
var settings = {
"url": "http://192.168.51.20/api/v4/call/originate/act",
"method": "PUT",
"timeout": 0,
"headers": {
"X-APIKEY": "9UV0BWKRL83PYIH9Gv1fI85d41lO4S932EeX3wHC47sHjMJOMG",
"Authorization": "Basic c2FkcjpTYWRyQDEyMw==",
"Content-Type": "application/json"
},
"data": JSON.stringify({
"caller": "31041570",
"callee": "09376131239",
"context": "main_routing",
"caller_id": "557",
"trunk_name": "Cisco",
"timeout": "30"
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
</script>
</body>
</html>
نمایش کامل کد Curl
curl --location --request PUT 'http://192.168.51.20/api/v4/call/originate/act' \
--header 'X-APIKEY: 9UV0BWKRL83PYIH9Gv1fI85d41lO4S932EeX3wHC47sHjMJOMG' \
--header 'Authorization: Basic c2FkcjpTYWRyQDEyMw==' \
--header 'Content-Type: application/json' \
--data-raw '{
"caller":"31041570",
"callee":"09376131239",
"context":"main_routing",
"caller_id":"557",
"trunk_name":"Cisco",
"timeout":"30"
}'
{
"success": 1,
"message": null,
"data": {
"originated_call_id": "orig.call.1703145054.787335"
}
}