我需要在英国办公时间以外的所有来电呼叫中拨打电话,所有来电呼叫都重定向到我们的下班时间。
我已经写了这本书,返回 $status = 'closed';
<?php
// set the timezone
date_default_timezone_set ('Europe/London');
function checkDateValue($val, $args) {
if (($val) >= $args['min'] && ($val) <= $args['max'] ) :
return true;
else :
return false;
endif ;
}
// set min and max valuesfor hours, minutes and seconds - format HH:MM:SS
$hours = array(
'min' => '09:00:00',
'max' => '17:30:00'
);
// set min and max values bwtween 0 nd 6. 0 = sunday
$days = array(
'min' => 1,
'max' => 5
);
// store current time
$currentTime = time();
// test if the current time is in opening hours or is a weekday
$status = 'open';
if (checkDateValue(date('H:i:s', $currentTime), $hours) === false || checkDateValue(date('w', $currentTime), $days) === false) {
$status = 'closed';
}
我想知道,PHP-SDK中是否有任何东西可以根据检测一周中的一天和一天的时间来处理有条件的拨号,并且还占当前呼叫者时区。
谢谢。
twilio开发人员在这里。
Twilio的PHP SDK或TWIML中没有什么可以为您完成此时间检测,您将需要编写自己的方法(如您所做的那样)来检测当前时间在几小时或小时内的响应中。
因此,您可以将当前脚本添加到以下内容之类的内容:
use TwilioTwiML;
$response = new TwiML;
if ($status == 'closed') {
$response->say("Sorry, the office is closed right now");
} else {
$response->dial($officePhone);
}
echo $response;
我不确定为什么您需要考虑当前呼叫者的时区,如果有人从法国打电话,您的英国时间就不会改变。也许您可以更细节发表评论或更新您的问题。否则,希望这会有所帮助。