先來(lái)看新用戶的注冊(cè)流程泳桦,注冊(cè)界面如下
點(diǎn)擊注冊(cè)事實(shí)上是以Post方式提交了一個(gè)Http請(qǐng)求
NSDictionary *dic = @{@"regsubmit":@"yes",@"un":avoidNullStr(username),@"pd":avoidNullStr(password),@"pd2":avoidNullStr(password2),@"em":avoidNullStr(email)};
[[ClanNetAPI sharedJsonClient] requestJsonDataWithPath:[NSString stringWithFormat:@"%@?version=%@&module=newuser&iyzmobile=1&inajax=1",_kurl_base_path,ClanVersion] withParams:dic withMethodType:Post andBlock:^(id data, NSError *error) {
if (error) {
block(error);
} else {
NSDictionary *dic = data[@"Message"];
if ([dic[@"messageval"] isEqualToString:@"register_succeed"]) {
//注冊(cè)成功 登錄
[ClanNetAPI saveCookieData];
[[NSUserDefaults standardUserDefaults] setObject:username forKey:@"kLASTUSERNAME"];
UserModel *user = [UserModel currentUserInfo];
[user setValueWithObject:[UserModel objectWithKeyValues:data]];
//設(shè)置登錄成功
user.logined = YES;
[UserModel saveToLocal];
if (fid) {
[self request_checkPostWithFid:fid];
}
}
block(data);
}
}];
分析下這個(gè)Http請(qǐng)求
- baseUrl: http://localhost/inspirelifebbs/
無(wú)疑這個(gè)是論壇網(wǎng)站的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中定義的module
$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這個(gè)參數(shù)就不太清楚它的用意傻唾。
然后再看source/plugin/bigapp/bigapp.php的源碼
$modules = array('forumnav', 'forumnav2', 'editpost', 'deletepm', 'deletepl', 'mythread2', 'delfav', 'login3body', 'newuser',
'captcha', 'checknewpm', 'myhome','myportal','secquestion', 'checkpost', 'forumupload', 'postsupport', 'search', 'searchuser',
'searchforum', 'threadrecommend2', 'newfriend', 'findfriend', 'addfriend', 'auditfriend', 'removefriend','plugcfg', 'report',
'platform_login', 'thrdtype', 'smilies', 'checkin', 'indexthread','favarticle','myfavarticle', 'indexcfg','contentthread', 'getaksk','modpass','viewinfo', 'activityclient', 'activityapplylist', 'viewratings','rate','ratepost','comment','commentmore','commentpost','commentnotice', 'removepost', 'removethread');
$defaultversions = array(
'forumnav' => 4,
'editpost' => 4,
'forumnav2' => 4,
'deletepm' => 4,
'deletepl' => 4,
'mythread2' => 4,
'delfav' => 4,
'login3body' => 4,
'newuser' => 4,
'captcha' => 4,
'checknewpm' => 4,
'checkpost' => 4,
'forumupload' => 4,
'postsupport' => 4,
'search' => 4,
'searchuser' => 4,
'searchforum' => 4,
'threadrecommend2' => 4,
'plugcfg' => 4,
'thrdtype' => 4,
'getaksk' => 4,
'getarticle' => 4,
'activityclient' => 4,
'activityapplylist' => 4,
'viewratings' => 4,
'rate' => 4,
'ratepost' => 4,
'removepost' => 4,
'removethread' => 4,
'newfriend' => 4,
'findfriend' => 4,
'addfriend' => 4,
'auditfriend' => 4,
'removefriend' => 4,
'report' => 4,
'platform_login' => 4,
'smilies' => 4,
'checkin' => 4,
'indexthread' => 4,
'myhome' => 4,
'testtids' => 4,
'modpass' => 4,
);
可以看到他定義了各個(gè)模塊以及模塊的版本谷饿,所以version=4&module=newuser這兩個(gè)參數(shù)應(yīng)該就是這邊需要的
例如apifile的定義
$apifile = dirname(__FILE__) . '/api/'.$_GET['iyzversion'].'/'.$_GET['module'].'.php';
- params:
參數(shù)以字典的形式定義惶我,在模塊中會(huì)讀取。根據(jù)上述定義博投,我們可以在source/plugin/bigapp/api/1/下找到newuser.php
if(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等參數(shù)听怕,所以這就是參數(shù)字典的來(lái)源。暫時(shí)不清楚regsubmit參數(shù)的作用虑绵。
{
em = "Test@hotmail.com";
pd = test;
pd2 = test;
regsubmit = yes;
un = Test;
}
- httpType: Post
-
returnValue:
在密碼等都設(shè)置正確之后尿瞭,最后的結(jié)果是返回“手機(jī)端暫不支持用戶注冊(cè)”
查看出錯(cuò)的這段定義,意味著!isset($_G['setting']['mobile']['mobileregister']) 沒(méi)有被定義或者為NO翅睛,那么這個(gè)_G['setting']是在哪里定義的声搁?
if(!isset($_G['setting']['mobile']['mobileregister']) || !$_G['setting']['mobile']['mobileregister']){
echo BIGAPPJSON::encode(array('error_code' => 7, 'error_msg' => lang('plugin/bigapp', 'forbid_mobreg'),
'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'forbid_mobreg'))));
die(0);
}
從插件的配置頁(yè)面可以得到的提示是該功能需要站長(zhǎng)認(rèn)證!
臨時(shí)的解決方案:
把這段檢查的代碼注釋掉捕发,同樣把error_code = 8的那段代碼注釋掉疏旨,最終可以注冊(cè)成功
工時(shí):
- 0.5 day