本文整理汇总了PHP中PhoneNumber::normalizePhoneNumberToE164方法的典型用法代码示例。如果您正苦于以下问题:PHP PhoneNumber::normalizePhoneNumberToE164方法的具体用法?PHP PhoneNumber::normalizePhoneNumberToE164怎么用?PHP PhoneNumber::normalizePhoneNumberToE164使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhoneNumber
的用法示例。
在下文中一共展示了PhoneNumber::normalizePhoneNumberToE164方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send_message
function send_message($from, $to, $message)
{
$from = PhoneNumber::normalizePhoneNumberToE164($from);
$to = PhoneNumber::normalizePhoneNumberToE164($to);
try {
$account = OpenVBX::getAccount();
$response = $account->messages->sendMessage($from, $to, $message);
} catch (Exception $e) {
throw new VBX_Sms_messageException($e->getMessage());
}
if (!in_array($response->status, array('sent', 'queued'))) {
throw new VBX_Sms_messageException('SMS delivery failed. An unknown error occurred' . ' during delivery.');
}
}
示例2: send_message
function send_message($from, $to, $message)
{
$from = PhoneNumber::normalizePhoneNumberToE164($from);
$to = PhoneNumber::normalizePhoneNumberToE164($to);
$twilio = new TwilioRestClient($this->twilio_sid, $this->twilio_token, $this->twilio_endpoint);
error_log("Sending sms from {$from} to {$to} with content: {$message}");
$response = $twilio->request("Accounts/{$this->twilio_sid}/SMS/Messages", 'POST', array("From" => $from, "To" => $to, "Body" => $message));
$status = isset($response->ResponseXml) ? $response->ResponseXml->SMSMessage->Status : 'failed';
if ($response->IsError || $status != 'sent' && $status != 'queued') {
error_log("SMS not sent - Error Occurred");
error_log($response->ErrorMessage);
throw new VBX_Sms_messageException($response->ErrorMessage);
}
}
示例3: make_call_path
function make_call_path($to, $callerid, $path, $rest_access)
{
$twilio = new TwilioRestClient($this->twilio_sid, $this->twilio_token);
$recording_url = site_url("twiml/redirect/{$path}/{$rest_access}");
$response = $twilio->request("Accounts/{$this->twilio_sid}/Calls", 'POST', array("Caller" => PhoneNumber::normalizePhoneNumberToE164($callerid), "Called" => PhoneNumber::normalizePhoneNumberToE164($to), "Url" => $recording_url));
if ($response->IsError) {
error_log($from);
error_log(var_export($response, true));
throw new VBX_CallException($response->ErrorMessage);
}
}
示例4: make_call
/**
* Start an outbound call
*
* @param string $from - the user making the call, this is the device that'll be called first
* @param string $to - the call destination
* @param string $callerid - the number to use as the caller id
* @param string $rest_access - token to authenticate the twiml request
* @return void
*/
public function make_call($from, $to, $callerid, $rest_access)
{
try {
PhoneNumber::validatePhoneNumber($from);
// handle being passed an email address for calls to browser clients
if (!filter_var($to, FILTER_VALIDATE_EMAIL)) {
PhoneNumber::validatePhoneNumber($to);
}
} catch (PhoneNumberException $e) {
throw new VBX_CallException($e->getMessage());
}
// don't normalize email addresses that are used to identify browser clients
if (!filter_var($to, FILTER_VALIDATE_EMAIL)) {
$to = PhoneNumber::normalizePhoneNumberToE164($to);
}
$callerid = PhoneNumber::normalizePhoneNumberToE164($callerid);
$from = PhoneNumber::normalizePhoneNumberToE164($from);
$twiml_url = site_url("twiml/dial") . '?' . http_build_query(compact('callerid', 'to', 'rest_access'));
try {
$account = OpenVBX::getAccount();
$account->calls->create($callerid, $from, $twiml_url);
} catch (Exception $e) {
throw new VBX_CallException($e->getMessage());
}
}