public function manage() { if (IS_POST) { if (isset($_POST['login'])) { // login $smsClient = new SmsClient(); $stats = $smsClient->login(); if ($stats !== null && $stats !== false && $stats == 0) { $this->success('登录成功!', U('Sms/index')); } else { echo '登录失败。错误码:' . $stats; //$this->error('登录失败!'.$stats, U('Sms/index')); } } else { if ($_POST['logout']) { // logout $smsClient = new SmsClient(); $stats = $smsClient->logout(); if ($stats !== null && $stats !== false && $stats == 0) { $this->success('注销成功!', U('Sms/index')); } else { echo '注销失败。错误码:' . $stats; //$this->error('注销失败!'.$stats, U('Sms/index')); } } } } }
<?php /** * Send message and check for delivery status until it is delivered. * * Use ../examples.php to test this file */ require_once '../oneapi/client.php'; # example:initialize-sms-client $smsClient = new SmsClient(USERNAME, PASSWORD); # ---------------------------------------------------------------------------------------------------- # example:login-sms-client $smsClient->login(); # ---------------------------------------------------------------------------------------------------- # example:prepare-message-without-notify-url $smsMessage = new SMSRequest(); $smsMessage->senderAddress = SENDER_ADDRESS; $smsMessage->address = DESTINATION_ADDRESS; $smsMessage->message = 'Hello world'; # ---------------------------------------------------------------------------------------------------- # example:send-message $smsMessageSendResult = $smsClient->sendSMS($smsMessage); # ---------------------------------------------------------------------------------------------------- // # example:send-message-client-correlator // The client correlator is a unique identifier of this api call: $clientCorrelator = $smsMessageSendResult->clientCorrelator; # ---------------------------------------------------------------------------------------------------- $deliveryStatus = null; for ($i = 0; $i < 4; $i++) { # example:query-for-delivery-status