Sir i have one issue in using asterisk version 16.4
i have created one api from an api template and working was good.
Now updated asterisk version from 16.2 to 16.4 and this api isn’t working
as before it was working.
actually behavior of api at asterisk 16.2, is getting remote caller id
of current call from cdr table from database.
but now asterisk 16.4 this api get remote caller id when agent hangup call.
Below is my API File
<?php
header('Access-Control-Allow-Origin: http://darewro.com', false);
if(!isset($_GET['extention_id'])){
echo 0;
exit();
}
$extention_id = (int) $_GET['extention_id'];
if($extention_id>0){
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "asterisk";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT `cdr_id`, `src` FROM `cdr` WHERE `calltype`=2 AND `disposition`='ANSWERED' AND `dst`='".$extention_id."' ORDER BY `calldate` DESC LIMIT 1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo $row["src"];
}
} else {
echo "No Call";
}
}else{
echo 0;
exit();
}
$conn->close();
?>
@like2143 Did you add custom fields to the CDR database? Because there is no cdr_id or calltype fields in the cdr table. So that’s query is going to fail unless you’ve added those fields.
Sir so how i can get remote caller id from current call.
Actually this api was working well with asterisk 16.2 .
can you help me to update this php file for getting remote caller id for current(live).
So then the answer is yes, you added custom fields to the CDR table in the database. The two fields I mentioned are not used by FreePBX in the CDR table schemea. Which means if they don’t exist, the query will fail.
Why don’t you add more debugging to your script so you can see what is actually happening with the query. Is it really returning 0 results or is it kicking back an error you’re not look at?