Discuz数据同步——DiscuzToolkit

公司想做个论坛,后来改用Discuz论坛,想实现一个功能,公司网站为主网站,通过在主站登陆,同时在Discuz论坛也实现登陆;

下面写具体操作步骤:

第一、在服务器上部署Discuz论坛;

第二、配置discuz论坛信息:登录系统后台管理——》扩展——》通行证设置——》设置相关信息;

第三、配置完毕后,主要是为了获取API Key、密钥、url

第四、编写代码部分,主程序中添加DiscuzToolkit.dll、Newtonsoft.Json.dll文件;

            public string api_key = "fd95b978adb8123f11608d87dbe940fb";
            public string secret = "9914c078e44c4ae5b96a54ebc91d86f1";
            public string url = "http://localhost:8080/";//论坛地址事实上

//登录事件
protected void btnLogin_Click(object sender, EventArgs e)
{
    DiscuzSession ds = new DiscuzSession(api_key, secret, url);
    int uid = ds.GetUserID("tianjie");
    ds.Login(uid, "123456", false, 10, "");
    Response.Redirect(url);
}

//注册事件
protected void btnLogin_Click(object sender, EventArgs e)
{
    DiscuzSession ds = new DiscuzSession(api_key, secret, url);
    ds.Register("tianjie", "123456", "[email protected]", false);
}

你可能感兴趣的:(Discuz数据同步——DiscuzToolkit)