/* * 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__ . '/common.php'; require_once __DIR__ . '/../lib/IMMN/IMMNService.php'; use Att\Api\IMMN\IMMNService; $arr = null; try { envinit(); $immnSrvc = new IMMNService(getFqdn(), getSessionToken()); $immnSrvc->createMessageIndex(); $arr = array('success' => true, 'text' => 'Message index created.'); } catch (Exception $e) { $arr = array('success' => false, 'text' => $e->getMessage()); } echo json_encode($arr); /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** * Sends an IMMN to a recipient, * * @method sendImmnMessage * * @param string $address addresses to which the specified messages will be sent. * @param string|null $text text body of message or null if none * @param string|null $subject subject of message or null if none * @param array|null $fnames file names of attachments or null if none * @param bool|null $isGroup whether to send as broadcast or null to use default * * @return {Response} Returns Response object * @throws ServiceException if API request was not successful. */ public function sendImmnMessage($address, $text, $subject, $fnames = null, $isGroup = false) { // Parse address(es) $address_array = array(); if (strstr($address, ",")) { // If it's csv, split and iterate over each value prepending each value with "tel:" $address = explode(",", $address); foreach ($address as $key => $value) { // Determine if string is tel, short or email array_push($address_array, $this->parseAddress($value)); } } else { array_push($address_array, $this->parseAddress($address)); } $token = $this->getSessionConsentToken('IMMN'); $immnSrvc = new IMMNService($this->base_url, $token); return $immnSrvc->sendMessage($address_array, $text, $subject, $fnames, $isGroup, true); }
/* * 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__ . '/common.php'; require_once __DIR__ . '/../lib/IMMN/IMMNService.php'; use Att\Api\IMMN\IMMNService; try { $msgId = $_POST['deleteMsgId']; envinit(); $immnSrvc = new IMMNService(getFqdn(), getSessionToken()); $immnSrvc->createMessageIndex(); $immnSrvc->deleteMessage($msgId); $arr = array('success' => true, 'text' => 'Message(s) Deleted'); } catch (Exception $e) { $arr = array('success' => false, 'text' => $e->getMessage()); } echo json_encode($arr); /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
* 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'; use Att\Api\IMMN\IMMNService; $arr = null; try { envinit(); $immnSrvc = new IMMNService(getFqdn(), getSessionToken()); $msgState = $_POST['msgState']; $deltaResponse = $immnSrvc->getMessagesDelta($msgState); $tables = array(); foreach ($deltaResponse->getDeltas() as $delta) { $values = array(); foreach ($delta->getAdds() as $add) { $values[] = array('Add', $add->getMessageId(), $add->isFavorite(), $add->isUnread()); } foreach ($delta->getDeletes() as $delete) { $values[] = array('Delete', $delete->getMessageId(), $delete->isFavorite(), $delete->isUnread()); } foreach ($delta->getUpdates() as $update) { $values[] = array('Update', $update->getMessageId(), $update->isFavorite(), $update->isUnread()); } $tables[] = array('caption' => 'Delta Type: ' . $delta->getDeltaType(), 'headers' => array('Delta Operation', 'MessageId', 'Favorite', 'Unread'), 'values' => $values);
* 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__ . '/common.php'; require_once __DIR__ . '/../lib/IMMN/IMMNService.php'; use Att\Api\IMMN\IMMNService; $arr = null; try { envinit(); $immnSrvc = new IMMNService(getFqdn(), getSessionToken()); $isUnread = $_POST['updateStatus'] == 'Read' ? false : true; $msgId = $_POST['updateMsgId']; $immnSrvc->updateMessage($msgId, $isUnread); $arr = array('success' => true, 'text' => 'Message(s) Updated'); } catch (Exception $e) { $arr = array('success' => false, 'text' => $e->getMessage()); } echo json_encode($arr); /* 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: */
public function handleGetNotifDetails() { $vnames = array('getNotifyDetails', 'queues'); $this->copyToSession($vnames); if (!isset($_SESSION['getNotifyDetails'])) { return; } try { if (!isset($_SESSION['queues'])) { throw new Exception('Invalid value for queues'); } $queues = strtoupper($_SESSION['queues']); if ($queues != 'TEXT' && $queues != 'MMS') { throw new Exception('Invalid value for queues'); } $immnSrvc = new IMMNService($this->apiFQDN, $this->getSessionToken()); $this->clearSession(array('getNotifyDetails')); $cd = $immnSrvc->getNotificationConnectionDetails($queues); $this->results[C_NOTIFICATION_DETAILS] = $cd; } catch (Exception $e) { $this->errors[C_NOTIFICATION_DETAILS] = $e->getMessage(); $this->clearSession(array('getNotifyDetails')); } }
* 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'; use Att\Api\IMMN\IMMNService; $arr = null; try { envinit(); $immnSrvc = new IMMNService(getFqdn(), getSessionToken()); $msgId = $_POST['contentMsgId']; $partNumber = $_POST['contentPartNumber']; $content = $immnSrvc->getMessageContent($msgId, $partNumber); $arr = array('success' => true); $splitType = explode('/', $content->getContentType()); $ctype = strtolower($splitType[0]); if ($ctype == 'text' || $ctype == 'plain') { $arr['text'] = 'Message Content: ' . $content->getContent(); } else { if ($ctype == 'image') { $arr['image'] = array('type' => $content->getContentType(), 'base64' => base64_encode($content->getContent())); } else { if ($ctype == 'video') { $arr['video'] = array('type' => $content->getContentType(), 'base64' => base64_encode($content->getContent())); } else {
/* * 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__ . '/common.php'; require_once __DIR__ . '/../lib/IMMN/IMMNService.php'; use Att\Api\IMMN\IMMNService; try { envinit(); $immnSrvc = new IMMNService(getFqdn(), getSessionToken()); $indexInfo = $immnSrvc->getMessageIndexInfo(); $tables = array(); $tables[] = array('caption' => 'Message Index Info:', 'headers' => array('Status', 'State', 'Message Count'), 'values' => array(array($indexInfo->getStatus(), $indexInfo->getState(), $indexInfo->getMessageCount()))); $arr = array('success' => true, 'tables' => $tables); } catch (Exception $e) { $arr = array('success' => false, 'text' => $e->getMessage()); } echo json_encode($arr); /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
$clientId = 'ENTER VALUE!'; // Enter the value from the 'App Secret' field obtained at developer.att.com // in your app account. $clientSecret = 'ENTER VALUE!'; // Get the OAuth code by opening a browser to the following URL: // https://api.att.com/oauth/v4/authorize?client_id=CLIENT_ID&scope=SCOPE&redirect_uri=REDIRECT_URI // replacing CLIENT_ID, SCOPE, and REDIRECT_URI with the values configured at // developer.att.com. // After authenticating, copy the OAuth code from the browser URL. $oauthCode = "ENTER VALUE!"; // Create the service for requesting an OAuth access token $osrvc = new OAuthTokenService('https://api.att.com', $clientId, $clientSecret); // Get the OAuth token using the OAuth code. $token = $osrvc->getTokenUsingCode(new OAuthCode($oauthCode)); // Create the service for interacting with the In-App Messaging API. $immnSrvc = new IMMNService('https://api.att.com', $token); // The following lines of code can be used to test the method calls for // the IMMNService class. To test a specific method, comment out // the other method. /* This try/catch block tests the sendMessage method. */ try { // Specify the address to where the message is sent. $addr = array('ENTER VALUE!'); // Send a test message. $response = $immnSrvc->sendMessage($addr, 'Text', 'Subject'); echo "msgId: " . $response . "\n"; } catch (ServiceException $se) { echo $se->getErrorResponse(); } /* This try/catch block tests the getMessageList method.*/ try {
* 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()); /* 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())); }
* 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: */