Please i need some help.
I have been reading about this API Twilio , because a have to solve some code that I didn't do.
And it is working on a page in PHP, to make calls to customers. There is a process that runs every often and check the log or cvs and inserts a record in the database with info Twilio.
Ideally, if at the end of the outgoing call, it could be know the unique ID of the call and save it along with some comments.
How can I take the parameters of the client-side call ? or there is other way? (duration, Sid, to, etc)
I already read this, but I don't get it
Thanks!!
https://www.twilio.com/docs/api/rest/making-calls
https://www.twilio.com/docs/api/rest/call
<?php
require_once('Services/Twilio.php'); // Loads the library
$API_VERSION = '2010-04-01';
$accountSid = 'AC7d3444f83611xxxxxxxxxxxxxxxx';
$authToken = 'd72d5f036e96abexxxxxxxxxxxxxx';
$capability = new Services_Twilio_Capability($accountSid, $authToken);
$capability->allowClientOutgoing('AP29cb5d9e0dcxxxxxxxxxxxxxxxxxx');
$capability->allowClientIncoming('name');
$token = $capability->generateToken();
//error_log("token is $token");
?>
<script type="text/javascript">
Twilio.Device.setup("<?php echo $token; ?>");
function call() {
params = {"PhoneNumber": $("#number_no").val(), "callerid": $("#callerid").val(), "agent_id": $("#agent_id").val(), "lead_id": $("#lead_id").val()};
Twilio.Device.connect(params);
}
function hangup() {
Twilio.Device.disconnectAll();
//Twilio.Device.disconnect();
}
</script>
This code is called when you update something
<script>
$(document).ready(function() {
$('.call_status').change(function()
{
var status = $(this).val();
var rec_val = $(this).parent().find('.rec_val').val();
var pledge_amt = $('#pledge_amt'+rec_val).val();
hangup();
$.ajax({
url: '<?php echo site_url('agent/agent_status/'); ?>',
type: 'post',
data: {'rec_val': rec_val, 'status': status, 'pledge_amt': pledge_amt},
success:function(resp)
{
if(resp)
{
window.location.href="<?php echo site_url('agent/call_leads/'); ?>";
//$('.msg').html("Status Updated Successfully!").fadeOut(5000);
} else
{
alert('Please check your selected data');
}
},
error:function(resp)
{
alert(resp);
}
});
});
jQuery('.status_update').fadeOut(5000);
});
</script>