先来看新用户的注册流程,注册界面如下
点击注册事实上是以Post方式提交了一个Http请求
1 |
NSDictionary *dic = @{@"regsubmit":@"yes",@"un":avoidNullStr(username),@"pd":avoidNullStr(password),@"pd2":avoidNullStr(password2),@"em":avoidNullStr(email)}; |
分析下这个Http请求
- baseUrl: http://localhost/inspirelifebbs/
无疑这个是论坛网站的URL - basePath: api/mobile/iyz_index.php?version=4&module=newuser&iyzmobile=1&inajax=1
api/mobile/iyz_index.php?为BigApp插件定义的mobile API。可以在api/mobile/找到源码。大概就是去找../../source/plugin/bigapp/bigapp.php中定义的module1
2
3
4
5
6
7$plugin = !empty($_GET['oem']) ? 'mobileoem' : 'mobile';
$file = 'mobile.php';
if(isset($_GET['iyzmobile']) && $_GET['iyzmobile']){
$plugin = 'bigapp';
$file = 'bigapp.php';
}
$dir = '../../source/plugin/'.$plugin.'/';
iyzmobile=1我猜大概就在这里需要用到。而inajax=1这个参数就不太清楚它的用意。
然后再看source/plugin/bigapp/bigapp.php的源码
1 |
$modules = array('forumnav', 'forumnav2', 'editpost', 'deletepm', 'deletepl', 'mythread2', 'delfav', 'login3body', 'newuser', |
可以看到他定义了各个模块以及模块的版本,所以version=4&module=newuser这两个参数应该就是这边需要的
例如apifile的定义
1 |
$apifile = dirname(__FILE__) . '/api/'.$_GET['iyzversion'].'/'.$_GET['module'].'.php'; |
- params:
参数以字典的形式定义,在模块中会读取。根据上述定义,我们可以在source/plugin/bigapp/api/1/下找到newuser.php1
2
3
4
5
6
7
8
9
10
11
12
13
14
15if(isset($_REQUEST['un']) && !empty($_REQUEST['un'])){
$userName = $_REQUEST['un'];
}
if(isset($_REQUEST['pd']) && !empty($_REQUEST['pd'])){
$password = $_REQUEST['pd'];
if(!isset($_REQUEST['pd2']) || $_REQUEST['pd2'] != $_REQUEST['pd']){
echo BIGAPPJSON::encode(array('error_code' => 1, 'error_msg' => lang('plugin/bigapp', 'password_not_equal'),
'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible',
'messagestr' => lang('plugin/bigapp', 'password_not_equal'))));
die(0);
}
}
if(isset($_REQUEST['em']) && !empty($_REQUEST['em'])){
$email = strtolower($_REQUEST['em']);
}
可以看到_REQUEST读取了em,pd,pd2,un等参数,所以这就是参数字典的来源。暂时不清楚regsubmit参数的作用。
{
em = “Test@hotmail.com”;
pd = test;
pd2 = test;
regsubmit = yes;
un = Test;
}
- httpType: Post
- returnValue:
在密码等都设置正确之后,最后的结果是返回“手机端暂不支持用户注册”
查看出错的这段定义,意味着!isset($_G[‘setting’][‘mobile’][‘mobileregister’]) 没有被定义或者为NO,那么这个_G[‘setting’]是在哪里定义的?
1 |
if(!isset($_G['setting']['mobile']['mobileregister']) || !$_G['setting']['mobile']['mobileregister']){ |
从插件的配置页面可以得到的提示是该功能需要站长认证!
临时的解决方案:
把这段检查的代码注释掉,同样把error_code = 8的那段代码注释掉,最终可以注册成功
工时:
- 0.5 day