Members Login
Username 
 
Password 
    Remember Me  
Post Info TOPIC: White Pages Mashup


Veteran Member

Status: Offline
Posts: 59
Date: Jul 9, 2009
White Pages Mashup
Permalink   
 


I recently wrote a mashup that uses reverse lookup information from Whitepages.com.  The mashup uses two Survos from Ifbyphone.  The first one simply passes the caller ID to the PHP code below.  The second Survo reads back the message we construct below.  You can hear the mashup in action (for a limited time) at 866.390.9675.  Here is the code:

<?php

// CAPTURE THE BUSINESS PHONE NUMBER SENT FROM IFBYPHONE
$phone = $_REQUEST['phone'];

//Add spaces to the phone number so TTS speaks it as single digits

for ($i=0; $i<=10; $i++) {
$formattedphonenum .= " " . substr($phone, $i, 1);
}

$valid_business_survo = "SURVOID";

$key = "WHITEPAGES.COMAPIKEY";
$url = "http://api.whitepages.com/reverse_phone/1.0/?phone=$phone&outputtype=JSON;api_key=$key";
$results = file_get_contents($url);
$obj = json_decode($results);

$message = "The number you are calling from is $formattedphonenum . . ";
$type = $obj->listings[0]->phonenumbers[0]->type;
if (is_null($type)){
$message .= "I cannot determine whether you are calling from a landline or a mobile phone. ";
} else{
$message .= "I think you are calling from a " . $type . " phone. ";
}
$displayname = $obj->listings[0]->displayname;
if (is_null($displayname)){
$message .= "Also, I could not find a name associated with this number";
}
else {
$message .= "I see that the name associated with this number is " . $obj->listings[0]->displayname;
}
$xml_return = "<action>
<app>survo</app>
<parameters>
<id>$valid_business_survo</id>
<user_parameters>
<message>$message</message>
</user_parameters>
</parameters>
</action>";
echo $xml_return;

?>

-- Edited by KhyleK on Friday 10th of July 2009 11:46:26 AM

__________________
Page 1 of 1  sorted by
 
Quick Reply

Please log in to post quick replies.

Post to Digg Post to Del.icio.us


Create your own FREE Forum
Report Abuse
Powered by ActiveBoard