private function _handleGetMessages() { if (!isset($_REQUEST['getMessages'])) { return; } $shortCode = $this->_getMsgsShortCode; try { $srvc = new SMSService($this->apiFQDN, $this->getFileToken()); $result = $srvc->getMessages($shortCode); $this->results[SMSController::RESULT_GET_MSGS] = $result; } catch (Exception $e) { $this->errors[SMSController::ERROR_GET_MSGS] = $e->getMessage(); } }
public function testRequest() { require __DIR__ . '/cfgs/sms_config.php'; if (isset($proxyHost) && isset($proxyPort)) { RestfulEnvironment::setProxy($proxyHost, $proxyPort); } if (isset($allowAllCerts)) { RestfulEnvironment::setAcceptAllCerts($allowAllCerts); } $osrvc = new OAuthTokenService($FQDN, $api_key, $secret_key); $token = $osrvc->getToken('SMS'); $srvc = new SMSService($FQDN, $token); $response = $srvc->getMessages($getMsgsShortCode); $this->assertTrue($response->getResourceUrl() != null); $response = $srvc->sendSMS($phoneNumber, 'test msg ok', false); $this->assertTrue($response->getMessageId() != null); $msgId = $response->getMessageId(); $response = $srvc->getSMSDeliveryStatus($msgId); $this->assertTrue($response->getResourceUrl() != null); }
try { // Specify the phone number where the SMS message is sent. // For example: $number = '5555555555'; $number = 'ENTER VALUE!'; // Send the SMS message to the specified phone number and // do not receive status notification. $response = $smsSrvc->sendSMS($number, 'Test Message', false); echo 'msgId: ' . $response->getMessageId() . "\n"; } catch (ServiceException $se) { echo $se->getErrorResponse(); } /* This try/catch block tests the getSMSDeliveryStatus method. */ try { // Enter the id of the SMS message. $smsId = 'ENTER VALUE!'; // Send the request for getting the SMS delivery status. $status = $smsSrvc->getSMSDeliveryStatus($smsId); echo 'resourceUrl: ' . $status->getResourceUrl() . "\n"; } catch (ServiceException $se) { echo $se->getErrorResponse(); } /* This try/catch block tests the getMessages method. */ try { // Enter the shortcode used to get the messages. $shortCode = 'ENTER VALUE!'; // Get the messages sent to the specified short code. $response = $smsSrvc->getMessages($shortCode); echo 'numberOfMsgs: ' . $response->getNumberOfMessages() . "\n"; } catch (ServiceException $se) { echo $se->getErrorResponse(); }
* * 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'; require_once __DIR__ . '/../lib/SMS/SMSService.php'; use Att\Api\Util\Util; use Att\Api\SMS\SMSService; $arr = null; try { envinit(); $smsService = new SMSService(getFqdn(), getFileToken()); $response = $smsService->getMessages(GET_MSGS_SHORT_CODE); $msgs = $response->getMessages(); $values = array(); foreach ($msgs as $msg) { $val = array($msg->getMessageId(), $msg->getSenderAddress(), $msg->getMessage()); $values[] = $val; } $arr = array('success' => true, 'tables' => array(array('caption' => "Message List Information:", 'headers' => array('Number of Messages In This Batch', 'Resource Url', 'Total Number of Pending Messages'), 'values' => array(array($response->getNumberOfMessages(), $response->getResourceUrl(), $response->getNumberOfPendingMessages()))), array('caption' => 'Messages', 'headers' => array('Message ID', 'Sender Address', 'Message'), 'values' => $values))); } catch (Exception $e) { $arr = array('success' => false, 'text' => $e->getMessage()); } echo json_encode($arr); /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** * Retrieves a list of SMSs sent to the application's short code * * @method getSms * * @param {string} registrationId The registrationId to receive messages from. * * @return {Response} Returns Response object * @throws ServiceException if API request was not successful. */ public function getSms($registrationId) { $token = $this->getCurrentClientToken(); $smsSrvc = new SMSService($this->base_url, $token); return $smsSrvc->getMessages($registrationId, true); }