コード例 #1
0
 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();
     }
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 * 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/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());
    $addr = Util::convertAddresses($_POST['address']);
    $addr = count($addr) == 1 ? $addr[0] : $addr;
    $msg = $_POST['message'];
    $notifyDeliveryStatus = isset($_POST['deliveryNotificationStatus']);
    $response = $smsService->sendSMS($addr, $msg, $notifyDeliveryStatus);
    $resourceUrl = $response->getResourceUrl();
    $resourceUrl = $resourceUrl == null ? '-' : $resourceUrl;
    $arr = array('success' => true, 'tables' => array(array('caption' => 'Message sent successfully', 'headers' => array('Message ID', 'Resource URL'), 'values' => array(array($response->getMessageId(), $resourceUrl)))));
} catch (Exception $e) {
    $arr = array('success' => false, 'text' => $e->getMessage());
}
echo json_encode($arr);
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
コード例 #4
0
ファイル: index.php プロジェクト: ryanbales/codekit-php
use Att\Api\SMS\SMSService;
// Use the app account settings from developer.att.com for the following values.
// Make sure that the API scope is set to SMS for the SMS API before
// retrieving the App Key and App Secret.
// Enter the value from the 'App Key' field obtained at developer.att.com
// in your app account.
$clientId = 'ENTER VALUE!';
// Enter the value from the 'App Secret' field obtained at developer.att.com
// in your app account.
$clientSecret = 'ENTER VALUE!';
// Create the service for requesting an OAuth access token.
$osrvc = new OAuthTokenService('https://api.att.com', $clientId, $clientSecret);
// Get the OAuth access token using the SMS scope.
$token = $osrvc->getToken('SMS');
// Create the service for interacting with the SMS API.
$smsSrvc = new SMSService('https://api.att.com', $token);
/* This try/catch block tests the sendSMS method. */
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.
コード例 #5
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';
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: */
コード例 #6
0
 /**
  * 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);
 }
コード例 #7
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/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: */