Jim Meehan had posted something to asterisk-users a couple of months ago
that looked up CID info from Google and, failing that, got the NPA/NXX info
from areacodedownload.com. I modified his script to look up Google, then
look up 411.com, since the latter has Canadian listings. I left Google in
because it's significantly faster. I removed the reversing first/last names
and the NPA/NXX lookup. Here the code, if anyone is interested:


#!/usr/bin/perl
use Asterisk::AGI;
$AGI = new Asterisk::AGI;
$number = $ARGV[0];
$found = 0;

open(RESULTS, "/usr/bin/curl -s -m 2 -A Mozilla/4.0
http://www.google.com/search?q=phonebook:$number |");
while (<RESULTS>) {
  if (m/Residential Phonebook/ || m/Business Phonebook/) {
    $found = 1;
    @fields = split(/>/);
    @result = split(/-/, $fields[35]);
    chop($result[0]);
    $name = $result[0];
  }
  if (m/did not match any/) {
    $found = 0;
  }
}

if ($found == 0) {
  open(RESULTS, "/usr/bin/curl -s -m 2 -A Mozilla/4.0
http://www.411.com/10668/search/Reverse_Phone?phone=$number |");
  while (<RESULTS>) {
    if (m/__FIRST/) {
      $found = 1;
      @fname = split(/\"/);
    }
    elsif (m/__LAST/) {
      @lname = split(/\"/);
      $name = $fname[1] . " " .$lname[1];
    }
  }
}

$AGI->set_variable('googlename', "\"$name\"");

--
Nabeel Jafferali
X2 Networks
www.x2n.ca
T: 1.647.722.6900
   1.877.VOIP.X2N
F: 1.866.655.6698
FWD: 46990



Reply via email to