使用android app连接到Vbulletin论坛

时间:2011-09-28 14:49:26

标签: android vbulletin

我正在尝试创建一个连接到vbulletin论坛的小应用,以检索用户面板中未读主题的数量。

我找到了如何从网站检索信息,但问题是我不知道如何登录论坛。

有人可以给我一个建议或至少一个链接来帮助我开始吗?

2 个答案:

答案 0 :(得分:0)

登录网站有多种方式:表格登录,http认证,通过AJAX登录等。

您需要调查在特定网站的情况下如何完成登录。

检查http连接(例如Firefox和Firebug可以看到连接),看看点击网站上的登录按钮时建立了什么样的连接。

答案 1 :(得分:0)

您需要通过您的应用程序使用用户名和用户密码的md5哈希发送_POST请求。用户名字段名称应为“vb_login_username”,密码字段名称应为“vb_login_md5password”。一旦弄明白,您就可以创建自己的应用程序与之对话的自定义登录页面。这是类似于我使用的东西。它在成功登录时以JSON格式返回用户的信息。

require_once('./global.php');
require_once(DIR . '/includes/functions_login.php');

define("BADLOGIN"              , "You have entered an invalid username or password.");
define("BADLOGIN_STRIKES"      , "You have entered an invalid username or password. You have %s login attempts left, after which you will be unable to login for 15 minutes.");
define("BADLOGIN_STRIKES_ZERO" , "You have entered an invalid username or password and used up your failed login quota. Please wait 15 minutes before trying to login again.");

// ################################ start login #################################
if ($_POST['do'] == 'login') {

    $vbulletin->input->clean_array_gpc('p', array(
        'vb_login_username'        => TYPE_STR,
        'vb_login_password'        => TYPE_STR,
        'vb_login_md5password'     => TYPE_STR,
        'vb_login_md5password_utf' => TYPE_STR,
        'cookieuser'               => TYPE_BOOL,
    ));

    // can the user login?
    $strikes = verify_strike_status($vbulletin->GPC['vb_login_username']);

    // make sure our user info stays as whoever we were (for example, we might be logged in via cookies already)
    $original_userinfo = $vbulletin->userinfo;

    if (!verify_authentication(
        $vbulletin->GPC['vb_login_username'], $vbulletin->GPC['vb_login_password'], 
        $vbulletin->GPC['vb_login_md5password'], $vbulletin->GPC['vb_login_md5password_utf'], 
        $vbulletin->GPC['cookieuser'], true)) 
    {       
        exec_strike_user($vbulletin->userinfo['username']);

        // load original user
        $vbulletin->userinfo = $original_userinfo;

        if ($vbulletin->options['usestrikesystem'])
        {
            if ((5 - $strikes) == 0)
            {
                die(json_encode(array(
                    'hasErrors' => (int) 1,
                    'errorMsg'  => BADLOGIN_STRIKES_ZERO
                ))); 
            }
            else
            {
                die(json_encode(array(
                    'hasErrors' => (int) 1,
                    'errorMsg'  => sprintf(BADLOGIN_STRIKES, 5 - $strikes)
                ))); 
            }
        }
        else
        {
            die(json_encode(array(
                'hasErrors' => (int) 1,
                'errorMsg'  => BADLOGIN
            ))); 
        }
    }

    exec_unstrike_user($vbulletin->GPC['vb_login_username']);

    // create new session
    process_new_login($vbulletin->GPC['logintype'], $vbulletin->GPC['cookieuser'], $vbulletin->GPC['cssprefs']);
    $userinfo = fetch_user($vbulletin->userinfo['userid']);

    // is banned user?
    if ($userinfo['usergroupid'] == 8) {
        process_logout();
    }

    // return userinfo
    die(json_encode(array(
        'success' => (int) 1,
        'user'    => $userinfo
    ))); 
}

希望这有助于您入门。顺便说一下,将字段名称“cookieuser”设置为true,并在下次发出请求时记住用户。

相关问题