Calling people with GrandCentral and Perl

Posted by hardwarehank, Sun Nov 05 08:39:06 UTC 2006

I wrote a script today that does a POST to a currently logged in GrandCentral user’s account using Firefox or Mozilla cookies. It’s quite simple really:


#!/usr/bin/perl -w
# Calls someone using the currently logged in account on GrandCentral.com
# User must log in to create the cookie in FireFox or Mozilla
# Then, the FIREFOX_PROFILE Environment variable must be set to the profile
#   directory containing the GrandCentral cookie.
# Finally, the script must be called using 2 10-digit phone numbers
#   - The first is the local phone number, which is the one you want to use
#   - The second is the remote phone number, which is the one you are calling.

use strict;
use LWP::UserAgent;
use HTTP::Cookies;

my $argcount = $#ARGV + 1;

# Die unless we have exactly 2 arguments and they both are 10-digit numbers
unless($argcount == 2 and $ARGV[0] =~ /^\d{10}$/ and $ARGV[1] =~ /^\d{10}$/) {
    die("Usage: $0 <Your 10-digit Phone Number> <Their 10-digit Phone
Number>\n");
}

my ($mynum, $destnum) = @ARGV;
my $cookie_file = $ENV{'FIREFOX_PROFILE'}."/cookies.txt";
print $cookie_file, "\n";
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
$ua->cookie_jar( HTTP::Cookies::Netscape->new( file => $cookie_file ));


my $req = HTTP::Request->new(POST => 'http://www.grandcentral.com/calls/send_call_request');

$req->content_type('application/x-www-form-urlencoded');
$req->content("calltype=call&destno=$destnum&ani=$mynum&_=");

my $res = $ua->request($req);
print $res->as_string;

Horray. Now, log into GrandCentral, point your FIREFOX_PROFILE Environment variable at your profile directory, and fire:


# Phone numbers have been changed to protect the innocent
./grandcentral_dialer 3748372637 7382737485

Whoa! The phone rings! Amazing!! I should add some more functionality to it - maybe have it pull from a DB of people and allow searching for phone numbers. Or maybe I could integrate it into some Linux address book and allow you to directly call people from that. Hmm…the possibilities are endless.

Tags:

Comments

Have your say

A name is required. You may use Markdown in your comments.