If there is an imprecise coding area, I hope you will forgive and give the pertinent advice.
Consolidation needs to be added to the original project by discuz! NT-Provided
Discuztoolkit Language Pack (C #)
In addition, in order to facilitate integration, I also wrote a simple project Dntaddnetsns, used to discuz! NT and SNS do some simple bonding.
Now let's show you some code snippets involving API calls:
Copy Code code as follows:
Integration code between the DNT
Try
{
Discuz.Toolkit.DiscuzSession ds = Conformityhandler.initdiscuzsession ();
Ds. Register (Conformityhandler.creatediscuzntusername (UI). Email), UI. Password, UI. Email, false);
ret = User.register (UI);//sns registration, obtaining registration information
}
catch (Discuz.Toolkit.DiscuzException D)
{
if (D.errorcode = 109)
{
ret = enumregister.emailrepeat;
}
}
//
The above is an instance of registering a user with a method in Discuztoolkit. (source code in Register.aspx.cs)
Involves the user's security information operation, needs to obtain the Authtoken, obtains the Authtoken to request the forum Login.aspx?api_key=[key], Then the forum will return to the set of callback address by a authtoken, the integration needs to use Authtoken place very much, but callback address can only set one, in response to this situation, I have created a new page dntapihandler.aspx, this page has no content, only used to do callback relay, that is, in discuz! The callback address is set to Dntapihandler.aspx in NT. The final application page is then determined based on the next parameter.
Finally listed to be added to the integration of the code page, easy to see the source.
Copy Code code as follows:
Web.config
Global.asax
Register.aspx
User/default.aspx
Login.aspx
Logout.aspx
Accountset.aspx
Userbase.aspx
As on the page some only changed its. CS files, some have modified.
If you want to use this consolidation project, you need to install the deployment according to the SNS installation instructions. and in order to achieve synchronous login (because SNS and no API, so the forum can not control SNS login), need to modify a discuz! NT Template login.htm, add the following code inside.
Copy Code code as follows:
<%csharp%>
If (request["Api_key"]==null&&request.form["username"]!= "admin")
Response.Redirect ("SNS login page path");
<%/csharp%>
Click to download Source Http://xiazai.jb51.net/200911/yuanma/dnt_netsns_src.zip