iwebshop短信接口修改,56短信接口目前适用于市场上所有的商城、CMS、手机APP、网站等,无论您的程序是那个版本,您在修改中或调到短信接口中遇到问题可以随时联系我们技术人员,微信QQ同号:QQ:826585910,我们将为您提供免费的技术支持,如果您对代码不懂,可以联系我们技术人员帮您免费接入调试。
private $submitUrl = "http://jiekou.56dxw.com/sms/webinterface.aspx";
/**
* @brief 获取config用户配置
* @return array
*/
public function getConfig()
{
$siteConfigObj = new Config("site_config");
return array(
'username' => $siteConfigObj->sms_username,
'userpwd' => $siteConfigObj->sms_pwd,
);
}
/**
* @brief 发送短信
* @param string $mobile
* @param string $content
* @return
*/
public function send($mobile,$content)
{
$config = self::getConfig();
$post_data = array(
'account' => $config['username'],
'password' => $config['userpwd'],
'mobile' => $mobile,
'content' => $content,
);
$url = $this->submitUrl;
$string = '';
foreach ($post_data as $k => $v)
{
$string .="$k=".urlencode($v).'&';
}
$post_string = substr($string,0,-1);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //如果需要将结果直接返回到变量里,那加上这句。
$result = curl_exec($ch);
return $this->response($result);
}