private function _handleGetSMSDeliveryStatus() { if (!isset($_REQUEST['getStatus'])) { return; } try { $id = $_REQUEST['messageId']; $_SESSION['SmsId'] = $id; $srvc = new SMSService($this->apiFQDN, $this->getFileToken()); $result = $srvc->getSMSDeliveryStatus($id); $this->results[SMSController::RESULT_SMS_DELIVERY] = $result; } catch (Exception $e) { $this->errors[SMSController::ERROR_SMS_DELIVERY] = $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(); }
/** * Check the status of a sent SMS * * @method smsStatus * * @param {string} smsId The unique SMS ID as retrieved from the response of the sendSms method * * @return {Response} Returns Response object * @throws ServiceException if API request was not successful. */ public function smsStatus($smsId) { $token = $this->getCurrentClientToken(); $smsSrvc = new SMSService($this->base_url, $token); return $smsSrvc->getSMSDeliveryStatus($smsId, true); }
* 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/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()); $msgId = $_POST['messageId']; $response = $smsService->getSMSDeliveryStatus($msgId); $resourceUrl = $response->getResourceUrl(); $values = array(); $dinfoList = $response->getDeliveryInfoList(); foreach ($dinfoList as $dinfo) { $val = array($dinfo->getId(), $dinfo->getAddress(), $dinfo->getDeliveryStatus()); $values[] = $val; } $arr = array('success' => true, 'tables' => array(array('caption' => "Resource URL: {$resourceUrl}", 'headers' => array('Message ID', 'Address', 'Delivery Status'), '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: */