恭维。用php代码在线发送短信
我是新来的PHP,但我一直在尝试在我的网站上创建一个短信平台/通知,以补充已经创建的通讯通知,但我迷失在如何初始化多个变量作为一个单位在我的工作php代码。步骤如下:
//i favour if...elseif over the switch method
//to declare the gateways variables
//step one. declaring gateways variables
$us_ca = array ('@txt.att.net', '@smscellular.com', '@more_gateways');
$nig = array ('@smsairtel.ng.com', '@more_gateways');
$gha = array ('@txt.mtn.com.gh', '@more_gateways');
..................................................
//note that the gateways are not correct but only cited as samples.
// i use more_gateways to represent others i couldn't write
// because of time and space
//step two. where the sms gets delivered.
if zip_code == '+1' {
email = '$telephone$us_ca', '$zip_code$telephone$us_ca'; //telephone
var for user's telephone, i create a second because some gateways
requires the country zip code.
} elseif zip_code == '+234'{
email = '$telephone$nig', '$zip_code$telephone$nig';
} elseif zip_code == '+233'{
email = '$telephone$gha', '$zip_code$telephone$gha';
}
........................................................
//note that i am targeting almost 90 countries.
现在我想知道的是,如果它的好宣布阵列VAR网关如上步骤之一,如果完成初始化多个变种我在第二个步骤”不是个做的方式不好。
请注意,每个短信同时发送到阵列中的所有网关,因为每个单独的电话号码对于在特定国家/地区提交的用户来说是唯一的,所以短信只能发送给用户即使它首先到达所有的网关。
在此先感谢。在简单的PHP函数
你不能直接从PHP发送短信。您可以尝试twilio或smsgh –
我想我已经在网上看过帖子,证实可以通过php发送短信。做一个彻底的在线检查,看看你自己;事实上,我通过我的研究得到了方法,但是据说一次可以通过电子邮件发送一个网关(或一组网关),但我想知道在这种情况下是否可以添加var。或如下所示: 如果zip_code =='+1'{ email ='$ zip_code。= $ telephone。= $ us_ca' } 感谢您的回复。 – test
检查了这一点。 https://code.tutsplus.com/tutorials/how-to-send-text-messages-with-php--net-17693 –