本文整理匯總了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;
}
}
}