连接到vBulletin论坛,Android应用程序 [英] Connect to Vbulletin forum with android app

查看:343
本文介绍了连接到vBulletin论坛,Android应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个小的应用程序,连接到一个vBulletin论坛检索未读的科目的数量在用户面板。

I'm trying to make a small app that connect to a vbulletin forum to retrieve the numbers of unread subjects in user panel.

我发现如何从一个网站的信息,但问题是我不知道如何登录到论坛。

I found how to retrieve info from a website, but the problem is I have no idea how to login to the forum.

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

Can someone give me an advice or a least a link to help me start ?

推荐答案

您将需要通过您的应用程序使用的用户名和用户密码的MD5哈希发送_ POST请求。用户名字段名应该是vb_login_username和密码字段名称应该是vb_login_md5password。一旦你明白这一点,你可以创建自己的自定义登录页面,您的应用程序会谈。下面是类似我用什么东西。它返回一个成功的登录JSON格式用户的信息。

You'll need to send a _POST request via your app with the username and an md5 hash of the user's password. The username field name should be "vb_login_username" and the password field name should be "vb_login_md5password". Once you figure that out, you can create your own custom login page that your app talks to. Here's something similar to what I use. It returns the user's information in JSON format on a successful login.

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,用户将在下一次发出请求时记住了。

Hopefully this helps get you started. By the way, set the field name "cookieuser" to true and the user will be remembered the next time a request is made.

这篇关于连接到vBulletin论坛,Android应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆