• 4001-021-502
您的位置:短信宝 > 技术分享 > 蚂蚁分类新增短信宝短信接口
蚂蚁分类新增短信宝短信接口
发表日期:2018-06-25    文章编辑:短信宝小编    浏览次数:

蚂蚁分类是一款基于php+mysql的分类信息/地方门户网站建站系统.为在各种服务器上架设分类信息网站提供完美的解决方案。它是免费的和开源的,使用范围非常广泛,小编对他还是比较了解的,今天小编为大家讲解mymps 5.8SE UTF-8版本的短信接口替换,使用的接口是我们短信宝群发平台的短信接口,我们短信宝群发短信平台非常稳定,发送速度快,注册还送测试短信,推荐大家使用。

首先,我们先更换后台的显示界面文件。打开模板文件,替换一下模板文件。打开项目/admin/template/sms_setting.tpl.php,替换的代码为11~14行,代码如下图所示:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<label for="dxton">
<input class="radio" name="sms_service" type="radio" id="dxton" value="dxton" onclick='document.getElementById("sms_div").style.display = "";'
<?
php if($sms_config[sms_service] == 'dxton')
{?>checked="checked"<?}
?>>
短信宝,点击<a href='http://www.smsbao.com/reg ' target='_blank'>免费注册</a>
</label>
<label for="ihuyi">
<input name="sms_service" type="radio" class="radio" id="ihuyi" value="ihuyi" onclick='document.getElementById("sms_div").style.display = "";'
<?php if($sms_config[sms_service] == 'ihuyi')
{?>checked="checked"<?}
?>>
通道二
</label>

经过替换后,第一步完成,接下来替换发送短信的业务代码。修改项目/include/dxtonmymps.php文件,代码如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
 
/**
 * 发送http请求
 * @access protected
 * @param string $url  请求地址
 * @param string $param  get方式请求内容,数组形式,post方式时无效
 * * @param string $data  post请求方式时的内容,get方式时无效
 * @param string $method  请求方式,默认get
 */
function http($url$param$data ''$method 'GET'){
 $opts array(
  CURLOPT_RETURNTRANSFER => 1,
  CURLOPT_SSL_VERIFYPEER => false,
  CURLOPT_SSL_VERIFYHOST => false,
 );
 
 /* 根据请求类型设置特定参数 */
 $opts[CURLOPT_URL] = $url '?' . http_build_query($param);
 
 if(strtoupper($method) == 'POST'){
  $opts[CURLOPT_POST] = 1;
  $opts[CURLOPT_POSTFIELDS] = $data;
 
  if(is_string($data)){ //发送JSON数据
   $opts[CURLOPT_HTTPHEADER] = array(
    'Content-Type: application/json; charset=utf-8',
    'Content-Length: ' strlen($data),
   );
  }
 }
 
 /* 初始化并执行curl请求 */
 $ch = curl_init();
 curl_setopt_array($ch$opts);
 $data  = curl_exec($ch);
 $error = curl_error($ch);
 curl_close($ch);
 
 //发生错误,抛出异常
 if($errorthrow new \Exception('请求发生错误:' $error);
 
 return  $data;
}
 
function msend_sms($sms_user$sms_pwd$mobile$content)
{
 
 $target 'http://api.smsbao.com/sms';
 $post_data['u']=$sms_user;
 $post_data['p']=md5($sms_pwd);
 $post_data['m']=$mobile;
 $post_data['c']=$content;
 echo $content;
 return $gets = http($target$post_data);
}
 
function msend_regsms($sms_user$sms_pwd$mobile$yzm$sms_regtpl '')
{
 $content str_replace('{code}'$yzm$sms_regtpl);
 $content str_replace('{mobile}'$mobile$content);
 $content = ($content $content '您的验证码是:' $yzm '。请不要把验证码泄露给其他人。如非本人操作,可不用理会!');
 $status = msend_sms($sms_user$sms_pwd$mobile$content);
 write_sms_sendrecord($mobile$content$status'smsbao');
}
 
function msend_pwdsms($sms_user$sms_pwd$mobile$yzm$sms_pwdtpl '')
{
 $content str_replace('{code}'$yzm$sms_pwdtpl);
 $content str_replace('{mobile}'$mobile$content);
 $content = ($content $content '您的手机号:' $mobile ',找回密码验证码:' $yzm ',请不要把验证码泄露给其他人。如非本人操作,可不用理会!');
 $status = msend_sms($sms_user$sms_pwd$mobile$content);
 write_sms_sendrecord($mobile$content$status'smsbao');
}
 
 
?>

好了,经过以上的替换,短信宝的短信平台已经替换成功了,可以正常使用了。我们进行测试发送。

报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。

另外:我们已经开发好完整的蚂蚁分类系统短信宝插件,点击此链接 下载及查看安装流程。

短信宝-做更好用的短信验证码短信营销短信群发服务平台。超过9,000个网站始终信任短信宝。通过稳定快捷的短信,短信宝帮助他们缩短了90%的人工服务处理时间,同时降低了81%由于通讯故障导致的废单率,一切变得轻松可控!

Copyright © 2010-2014 smsbao.com All Rights Reserved
上海子橙电子科技有限公司 沪ICP备14008182号-2 上海市松江区广富林路658弄215号

展开