Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #
- # THIS SCRIPT IS INCOMPLETE - work in progress
- use Asterisk::AGI;
- use LWP::UserAgent;
- use strict;
- # Set configuration parameters
- my $api_key = "YourAPIkey";
- my $api_password = "YourAPIpassword";
- my $service_url = "https://api.truecnam.net/api/v1";
- #############################################################
- #
- # Get data from Asterisk
- my $AGI = new Asterisk::AGI;
- my $calling_num = $AGI->get_variable("cidnum");
- my $called_num = $AGI->get_variable("callednum");
- # Send request to TrueCNAM
- my $url = $service_url."?username=".$api_key."&password=".$api_password."&resp_type=extended&resp_format=csv&calling_number=".$calling_num."&call_party=orig_call_start";
- $url .= "&called_number=".$called_num if ($called_num);
- my $content = "";
- my $ua = LWP::UserAgent->new;
- my $response = $ua->get($url);
- if ($response->is_success) {
- $content = $response->decoded_content;
- #print $response->decoded_content . "\n"; # or whatever
- } else {
- #die $response->status_line;
- exit 0;
- }
- my @res = split(",", $content);
- # https://support.truecnam.com/support/solutions/articles/5000592940-trueclid-call-start-api-call-in-depth
- # ok,0,
- # Check for error
- #if ($res[11]) {
- #exit 0;
- #}
- exit 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement