function initiateCallbacks($vendor_events) { require_once "service/SimplePdoLeadConnectService.php"; $service = new SimplePdoLeadConnectService(); // Include the Twilio PHP library require 'twilio-php-master/Services/Twilio.php'; // Twilio REST API version $version = "2010-04-01"; // Set our Account SID and AuthToken $sid = 'AC3b2e8a3fabcbfe627c092046e3023ce4'; $call_initiated = 0; foreach ($vendor_events as $vendor) { if ($call_initiated == 0) { if (in_array('callback', $vendor)) { if (!in_array('completed', $vendor)) { $vendor_id = $vendor[1]; $inquiry_id = $vendor[2]; $pi = $service->loadProspectInquiry($inquiry_id); $name = urlencode($pi->name); $phone = $pi->phone; $inquiry_key = $pi->inquiry_key; $vendor = $service->loadVendor($vendor_id); $account = $service->loadAccount($pi->account_id); $token = $account->api_key; $client = new Services_Twilio($sid, $token, $version); $call = $client->account->calls->create($account->phone, '+1' . $vendor->phone, 'http://' . $_SERVER["HTTP_HOST"] . '/vendor-connect.php?phone=' . $phone . '&name=' . $name . '&inquiry-key=' . $inquiry_key . '&vendor-id=' . $vendor->id . '&callback=true'); $call_initiated = 1; } } } } }
<?php require_once "service/SimplePdoLeadConnectService.php"; require_once "entity/Account.php"; $service = new SimplePdoLeadConnectService(); if (array_key_exists('id', $_POST) && $_POST['id']) { $account = $service->loadAccount($_POST['id']); } else { $account = new Account(); } $a = new Account(); if (array_key_exists('id', $_POST) && $_POST['id']) { $a->id = $_POST['id']; } $a->name = $_POST['name']; $a->host = $_POST['host']; $a->phone = $_POST['phone']; $a->api_key = $_POST['api_key']; $a->number_sid = $_POST['number_sid']; $a->greeting = $_POST['greeting']; if ($service->saveAccount($a)) { header("Location: accounts.php?message=Saved"); } else { header("Location: error.php"); }
header("content-type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; require_once "service/SimplePdoLeadConnectService.php"; require_once "entity/Inquiry.php"; require_once "entity/Event.php"; require_once "functions.php"; $sid = $_GET['sid']; $live = $_GET['live']; $phone = $_GET['phone']; $name = $_GET['name']; $inquiry_key = $_GET['inquiry-key']; $vendor_id = $_GET['vendor-id']; $params = "phone={$phone}&vendor-id={$vendor_id}&inquiry-key={$inquiry_key}&sid={$sid}&live={$live}"; $service = new SimplePdoLeadConnectService(); $vendor = $service->loadVendor($vendor_id); $account = $service->loadAccount($vendor->account_id); $inquiry = $service->loadInquiry($inquiry_key); $events = $service->loadEvents($inquiry->id); ?> <Response> <?php if (count($events) > 0) { $vendor_events = groupEventsByVendor($events); $call_in_process = detectCallInProcess($vendor_events); if ($call_in_process == 1) { if ($live == "true") { ?> <Say>Hello. Someone just called from <?php echo $account->name; ?>
<?php require_once "service/SimplePdoLeadConnectService.php"; require_once "entity/Account.php"; require_once "entity/Vendor.php"; if (array_key_exists('id', $_GET) && $_GET['id']) { $service = new SimplePdoLeadConnectService(); $account = $service->loadAccount($_GET['id']); $vendors = $service->loadAccountVendors($_GET['id']); } ?> <html> <head> <title>Account</title> </head> <body> <h1>Account</h1> <form method="post" action="_saveAccount.php"> <p> Name:<br /> <input type="text" name="name" <?php if (array_key_exists('id', $_GET) && $_GET['id']) { ?> value="<?php echo $account->name; } ?> "/> </p>