本文整理汇总了PHP中Sms::_post方法的典型用法代码示例。如果您正苦于以下问题:PHP Sms::_post方法的具体用法?PHP Sms::_post怎么用?PHP Sms::_post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sms
的用法示例。
在下文中一共展示了Sms::_post方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendSms
/**
*
* 批量发送短信
* @param array $mobile 手机号码
* @param string $content 短信内容
* @param datetime $send_time 发送时间
* @param string $charset 短信字符类型 gbk / utf-8
* @param string $id_code 唯一值 、可用于验证码
*/
public function sendSms($token, $content = '', $mobile = '', $send_time = '', $charset = 'utf-8', $id_code = '')
{
if (C('sms_key') != '' && C('sms_key') != 'key') {
$companyid = 0;
if (!(strpos($token, '_') === FALSE)) {
$sarr = explode('_', $token);
$token = $sarr[0];
$companyid = intval($sarr[1]);
}
if (!$mobile) {
$companyWhere = array();
$companyWhere['token'] = $token;
if ($companyid) {
$companyWhere['id'] = $companyid;
}
$company = M('Company')->where($companyWhere)->find();
$mobile = $company['mp'];
}
//
$thisWxUser = M('Wxuser')->where(array('token' => Sms::_safe_replace($token)))->find();
$thisUser = M('Users')->where(array('id' => $thisWxUser['uid']))->find();
if ($token == 'admin') {
$thisUser = array('id' => 0);
$thisWxUser = array('uid' => 0, 'token' => $this->token);
}
if (intval($thisUser['smscount']) < 1 && $token != 'admin') {
return '已用完或者未购买短信包';
exit;
} else {
//
//短信发送状态
if (is_array($mobile)) {
$mobile = implode(",", $mobile);
}
$content = Sms::_safe_replace($content);
$data = array('topdomain' => C('server_topdomain'), 'key' => trim(C('sms_key')), 'token' => $token, 'content' => $content, 'mobile' => $mobile, 'sign' => trim(C('sms_sign')));
$post = '';
foreach ($data as $k => $v) {
$post .= $k . '=' . $v . '&';
}
$smsapi_senturl = 'http://up.pigcms.cn/oa/admin.php?m=sms&c=sms&a=send';
$return = Sms::_post($smsapi_senturl, 0, $post);
$arr = explode('#', $return);
$this->statuscode = $arr[0];
//增加到本地数据库
if ($mobile) {
$row = array('uid' => $thisUser['id'], 'token' => $thisWxUser['token'], 'time' => time(), 'mp' => $mobile, 'text' => $content, 'status' => $this->statuscode, 'price' => C('sms_price'));
M('Sms_record')->add($row);
if (intval($this->statuscode) == 0 && $token != 'admin') {
M('Users')->where(array('id' => $thisWxUser['uid']))->setDec('smscount');
}
}
//end
return $return;
}
}
}