private function handleSendMMS() { if (!isset($_REQUEST['address'])) { return; } try { $this->copyToSession(array('address', 'subject', 'attachment', 'chkGetOnlineStatus')); $addr = Util::convertAddresses($_REQUEST['address']); $addr = count($addr) == 1 ? $addr[0] : $addr; $subject = $_REQUEST['subject']; $attachment = $_REQUEST['attachment']; $attachArr = array(); if (strcmp($attachment, '') != 0) { $attachArr = array('attachment/' . $attachment); } $notifyDeliveryStatus = isset($_REQUEST['chkGetOnlineStatus']); $srvc = new MMSService($this->apiFQDN, $this->getFileToken()); $response = $srvc->sendMMS($addr, $attachArr, $subject, null, $notifyDeliveryStatus); if (!$notifyDeliveryStatus) { $_SESSION['id'] = $response->getMessageId(); } $this->results[MMSController::RESULT_SEND_MMS] = $response; } catch (Exception $e) { $this->errors[MMSController::ERROR_SEND_MMS] = $e->getMessage(); } }
/** * Gets a file's MIME type. * * @param string $fname file name for which to get MIME type * * @return void */ public static function getFileMIMEType($fname) { // TODO: Move to file util // Try getMimeType2 first, if unknown go to finfo $ftype = Util::getMimeType2($fname); if ($ftype != 'unknown') { return $ftype; } // lazy init if (self::$_fileInfo == null) { self::$_fileInfo = new finfo(FILEINFO_MIME); } return self::$_fileInfo->file($fname); }
private function _handleSendSMS() { if (!isset($_REQUEST['sendSMS'])) { return; } try { $rawaddrs = $_REQUEST['address']; $_SESSION['rawaddrs'] = $rawaddrs; $addrArray = Util::convertAddresses($rawaddrs); $addr = count($addrArray) == 1 ? $addrArray[0] : $addrArray; $msg = $_REQUEST['message']; $getNotification = isset($_REQUEST['chkGetOnlineStatus']); $srvc = new SMSService($this->apiFQDN, $this->getFileToken()); $result = $srvc->sendSMS($addr, $msg, $getNotification); if (!$getNotification) { $_SESSION['SmsId'] = $result->getMessageId(); } $this->results[SMSController::RESULT_SEND_SMS] = $result; } catch (Exception $e) { $this->errors[SMSController::ERROR_SEND_SMS] = $e->getMessage(); } }
target="_blank">Download<img src="images/download.png" alt="Link"></a> <span class="divider">| </span> </li> <li><a href="<?php echo $linkHelp; ?> " target="_blank">Help</a></li> <li id="back"><a href="#top">Back to top</a></li> </ul> <!-- end of links --> </div> <!-- end of header --> <div class="content"> <div class="contentHeading"> <h1>AT&T Sample Application - Text To Speech</h1> <div id="introtext"> <div><b>Server Time: </b><?php echo Util::getServerTime(); ?> </div> <div> <b>Client Time: </b> <script> document.write("" + new Date()); </script> </div> <div> <b>User Agent: </b> <script> document.write("" + navigator.userAgent); </script> </div> </div> <!-- end of introtext -->
<?php /* * Copyright 2015 AT&T * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ session_start(); require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/common.php'; require_once __DIR__ . '/../lib/Util/Util.php'; use Att\Api\Util\Util; $arr = array('authenticated' => isSessionAuthenticated(), 'redirect_url' => getCodeLocation(), 'server_time' => Util::getServerTime(), 'download' => LINK_DOWNLOAD, 'github' => LINK_GITHUB); if (isset($_SESSION['savedData'])) { $arr['savedData'] = json_decode($_SESSION['savedData'], true); } echo json_encode($arr); /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** * Convenience method for adding file part. * * @param string $fname file location of file part. * * @return void */ public function addFilePart($fname) { // base name $bname = basename($fname); $cDisposition = 'form-data;'; $cDisposition .= ' name="x-voice";'; $cDisposition .= ' filename="' . $bname . '"'; // part headers $pheaders = array(); $pheaders['Content-Disposition'] = $cDisposition; $pheaders['Content-Type'] = Util::getFileMIMEType($fname); $pheaders['Content-Transfer-Encoding'] = 'binary'; $fileResource = fopen($fname, 'r'); if (!$fileResource) { throw new RuntimeException('Could not open file ' . $fname); } $fileBinary = fread($fileResource, filesize($fname)); fclose($fileResource); $this->addPart($pheaders, $fileBinary); }
<?php /* * Copyright 2014 AT&T * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ session_start(); require __DIR__ . '/../config.php'; require_once __DIR__ . '/../lib/Util/Util.php'; use Att\Api\Util\Util; $path = __DIR__ . '/../template/'; $xGrammar = $path . 'x-grammar.txt'; $xDictionary = $path . 'x-dictionary.txt'; $arr = array('authenticated' => true, 'server_time' => Util::getServerTime(), 'download' => $linkDownload, 'github' => $linkSource, 'x_grammar' => file_get_contents($xGrammar), 'x_dictionary' => file_get_contents($xDictionary)); if (isset($_SESSION['savedData'])) { $arr['savedData'] = json_decode($_SESSION['savedData'], true); } echo json_encode($arr);
<?php /* * Copyright 2015 AT&T * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ session_start(); require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/common.php'; require_once __DIR__ . '/../lib/Util/Util.php'; use Att\Api\Util\Util; $subscriptionActive = isset($_SESSION['subscriptionId']) ? true : false; $arr = array('authenticated' => isSessionAuthenticated(), 'redirect_url' => getCodeLocation(), 'server_time' => Util::getServerTime(), 'download' => LINK_DOWNLOAD, 'github' => LINK_GITHUB, 'notificationChannel' => array('channelId' => CHANNEL_ID, 'channelType' => CHANNEL_TYPE, 'maxEvents' => MAX_EVENTS, 'contentType' => CONTENT_TYPE), 'subscriptionActive' => $subscriptionActive); if (isset($_SESSION['savedData'])) { $arr['savedData'] = json_decode($_SESSION['savedData'], true); } echo json_encode($arr); /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
<?php /* * Copyright 2014 AT&T * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ session_start(); require __DIR__ . '/../config.php'; require_once __DIR__ . '/../lib/Util/Util.php'; use Att\Api\Util\Util; $arr = array('authenticated' => true, 'server_time' => Util::getServerTime(), 'download' => $linkDownload, 'github' => $linkGithub, 'notificationShortcode' => $notificationShortcode); if (isset($_SESSION['savedData'])) { $arr['savedData'] = json_decode($_SESSION['savedData'], true); } echo json_encode($arr); /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
use Att\Api\Util\Util; if (isset($_SESSION['subscriptionExpiry'])) { $tnow = time(); $expiry = $_SESSION['subscriptionExpiry']; if ($tnow >= $expiry) { unset($_SESSION['subscriptionId']); } } if (!isset($_SESSION['subscriptionId'])) { $arr = array('stopPolling' => true); echo json_encode($arr); return; } $subscriptionId = $_SESSION['subscriptionId']; $arr = FileUtil::loadArray(NOTIFICATION_FILE); $vals = array(); foreach ($arr as $msgNotifications) { foreach ($msgNotifications as $subscriptionNotifications) { $subId = $subscriptionNotifications['subscriptionId']; if ($subId != $subscriptionId) { continue; } $callbackData = $subscriptionNotifications['callbackData']; $notificationEvents = $subscriptionNotifications['notificationEvents']; foreach ($notificationEvents as $evt) { $vals[] = Util::convertNulls(array($subId, $callbackData, $evt['messageId'], $evt['conversationThreadId'], $evt['eventType'], $evt['event'], $evt['text'], $evt['isTextTruncated'], $evt['isFavorite'], $evt['isUnread'])); } } } echo json_encode($vals); /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
* You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ session_start(); require_once __DIR__ . '/common.php'; require_once __DIR__ . '/../lib/IMMN/IMMNService.php'; require_once __DIR__ . '/../lib/Util/Util.php'; use Att\Api\IMMN\IMMNService; use Att\Api\Util\Util; $arr = null; try { envinit(); $immnSrvc = new IMMNService(getFqdn(), getSessionToken()); $addrs = Util::convertAddresses($_POST['address']); $msg = $_POST['sendMsgInput']; $subject = $_POST['sendSubjectInput']; $group = isset($_POST['groupCheckbox']); $id = $immnSrvc->sendMessage($addrs, $msg, $subject, null, $group); $arr = array('success' => true, 'text' => 'id: ' . $id); } catch (Exception $e) { $arr = array('success' => false, 'text' => $e->getMessage()); } echo json_encode($arr); /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
use Att\Api\Util\Util; $postBody = file_get_contents('php://input'); if (strpos($postBody, "<SenderAddress>tel:+") == 0) { exit; } if (!is_dir($imagesPath)) { mkdir($imagesPath); } $messages = FileUtil::loadArray($imagesDbPath); $message = array(); preg_match("@<SenderAddress>tel:(.*)</SenderAddress>@i", $postBody, $matches); $addr = $matches[1]; $message["address"] = preg_replace('/\\d\\d\\d($)/', '***${1}', $addr); preg_match("@<subject>(.*)</subject>@i", $postBody, $matches); $message["subject"] = $matches[1]; $message["date"] = Util::getServerTime(); $message["id"] = count($messages); mkdir($imagesPath . '/' . $message["id"]); $boundaryParts = explode("--Nokia-mm-messageHandler-BoUnDaRy", $postBody); foreach ($boundaryParts as $mimePart) { if (!preg_match("@BASE64@", $mimePart)) { continue; } $mmPart = explode("BASE64", $mimePart); $filename = null; $contentType = null; if (preg_match("@Name=([^;^\n]+)@i", $mmPart[0], $matches)) { $filename = trim($matches[1]); } if (preg_match("@Content-Type:([^;^\n]+)@i", $mmPart[0], $matches)) { $contentType = trim($matches[1]);
session_start(); require_once __DIR__ . '/common.php'; require_once __DIR__ . '/../lib/IMMN/IMMNService.php'; require_once __DIR__ . '/../lib/Util/Util.php'; use Att\Api\IMMN\IMMNService; use Att\Api\Util\Util; $arr = null; try { envinit(); $immnSrvc = new IMMNService(getFqdn(), getSessionToken()); /* TODO: move to config */ $limit = 5; $offset = 0; $msgIds = null; $type = null; $fvt = isset($_POST['favorite']) ? $_POST['favorite'] : null; $unread = isset($_POST['unread']) ? true : false; $incoming = isset($_POST['incoming']) ? true : false; $keyword = $_POST['keyword']; $msgList = $immnSrvc->getMessageList($limit, $offset, $msgIds, $unread, $type, $keyword, $incoming, $fvt); $msgValues = array(); $msgs = $msgList->getMessages(); foreach ($msgs as $msg) { $msgValues[] = Util::convertNulls(array($msg->getMessageId(), $msg->getFrom(), $msg->getRecipients(), $msg->getText(), $msg->getTimeStamp(), $msg->isFavorite(), $msg->isUnread(), $msg->isIncoming(), $msg->getMessageType())); } $arr = array('success' => true, 'tables' => array(array('caption' => 'Details:', 'headers' => array('Limit', 'Offset', 'Total', 'Cache Status', 'Failed Messages', 'State'), 'values' => array(array($msgList->getLimit(), $msgList->getOffset(), $msgList->getTotal(), $msgList->getCacheStatus(), $msgList->getFailedMessages(), $msgList->getState()))), array('caption' => 'Messages:', 'headers' => array('Message ID', 'From', 'Recipients', 'Text', 'Timestamp', 'Favorite', 'Unread', 'Incoming', 'Type'), 'values' => $msgValues))); } catch (Exception $e) { $arr = array('success' => false, 'text' => $e->getMessage()); } echo json_encode($arr); /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
function generateWeburlsTable($contactId, $weburls) { if ($weburls === null || count($weburls) == 0) { return null; } $table = array(); $table['caption'] = "Contact ({$contactId}) Weburls:"; $table['headers'] = array('type', 'url', 'preferred'); $values = array(); foreach ($weburls as $weburl) { $values[] = Util::convertNulls(array($weburl->getWebUrlType(), $weburl->getUrl(), $weburl->isPreferred())); } $table['values'] = $values; return $table; }
<?php /* * Copyright 2015 AT&T * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ session_start(); require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/common.php'; require_once __DIR__ . '/../lib/Util/Util.php'; use Att\Api\Util\Util; $arr = array('authenticated' => true, 'server_time' => Util::getServerTime(), 'download' => LINK_DOWNLOAD, 'github' => LINK_GITHUB, 'short_code_check' => GET_MSGS_SHORT_CODE, 'short_code_received' => RECEIVE_MSGS_SHORT_CODE); if (isset($_SESSION['savedData'])) { $arr['savedData'] = json_decode($_SESSION['savedData'], true); } echo json_encode($arr); /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
<?php /* * Copyright 2014 AT&T * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ session_start(); require __DIR__ . '/../config.php'; require_once __DIR__ . '/../lib/Util/Util.php'; use Att\Api\Util\Util; $arr = array('authenticated' => true, 'server_time' => Util::getServerTime(), 'download' => $linkDownload, 'github' => $linkGithub); if (isset($_SESSION['savedData'])) { $arr['savedData'] = json_decode($_SESSION['savedData'], true); } echo json_encode($arr);
* you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ session_start(); require_once __DIR__ . '/common.php'; require_once __DIR__ . '/../lib/IMMN/IMMNService.php'; require_once __DIR__ . '/../lib/Util/Util.php'; use Att\Api\IMMN\IMMNService; use Att\Api\Util\Util; $arr = null; try { envinit(); $immnSrvc = new IMMNService(getFqdn(), getSessionToken()); $msgId = $_POST['getMsgId']; $msg = $immnSrvc->getMessage($msgId); $msgValues = array($msg->getMessageId(), $msg->getFrom(), $msg->getRecipients(), $msg->getText(), $msg->getTimeStamp(), $msg->isFavorite(), $msg->isUnread(), $msg->isIncoming(), $msg->getMessageType()); $msgValues = Util::convertNulls($msgValues); $arr = array('success' => true, 'tables' => array(array('caption' => 'Message:', 'headers' => array('message id', 'from', 'recipients', 'text', 'timestamp', 'isFavorite', 'isUnread', 'isIncoming', 'type'), 'values' => array($msgValues)))); } catch (Exception $e) { $arr = array('success' => false, 'text' => $e->getMessage()); } echo json_encode($arr); /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */