ASP. NET integration Discuz! NT3.5 instance description (including user logon and comments)

Source: Internet
Author: User
A while ago I wanted to create a group-buying navigation website. I saw some group-buying navigation sites have forums, and I also wanted to add one. I studied Discuz! NT, found that there is an API interface, suddenly thought of using Discuz! It is not convenient for NT to integrate the website. Members do not need to develop their own websites.

Let's just do it. I went down to the API examples and the Development Kit and looked at it again, but it was still confused. I don't know if I was too stupid. In addition, I found that there are still errors in the API. It seems that I have not been answered for help from the official forum. It seems that I can only rely on myself. After reading the N-times, I finally understood the general idea. The whole API was familiar with the usage method and found that although the API was convenient, there were a lot of problems. The user's redirection behavior after login (continuously jumping, the efficiency is too low, which affects search engine indexing.) there is also the "Code: 103, Message: the call_id submitted by the current session is not greater than the previous call_id" error, even more, I was totally depressed about the API. Finally, I had to use the second method to download the source code and integrate it myself + Discuz! Nt api.

Fortunately, Discuz! NT is an open-source program. Otherwise, I will give up using it. Let's talk about my website Xuzhou 86516 group buying navigation: http://www.86516tuan.com/. we can see that my primary account has integrated the user's status and Information (login and registration are completed in the Forum), logout after login, user comments, Automatic posting, and scheduled tasks in the system background. The following describes the integration method, which requires Discuz! Nt dll. I put all the DLL files under the bin directory of my website and attached the code.

1. User Login status and login information acquisition

Using Discuz. Forum;
Using Discuz. Entity;

String discuzName = string. Empty;
If (Request. Cookies ["dnt"]! = Null)
{
// Log on
Int uid = Convert. ToInt32 (Request. Cookies ["dnt"] ["userid"]);
// Obtain logon user information
UserInfo info = Users. GetUserInfo (uid );
If (info! = Null)
{
DiscuzName = info. Username;
}
Else
{
DiscuzSession ds = DiscuzSessionHelper. GetSession ();
Ds. Logout (string. Empty );
}
}
Else
{
// Not logged on
}

2, log out, the need for API DiscuzToolKit dll Development Kit, is: http://nt.discuz.net/showtopic-81187.html

Using Discuz. Toolkit;

DiscuzSession ds = DiscuzSessionHelper. GetSession ();
Ds. Logout (string. Empty );

3. Automatic posting. Every time I collect a group buying data, I will send it to Discuz! NT Forum sends a post, and both sides use the ID corresponding
For example, logging
The API is used to automatically create a topic. For details about the parameters, see the official API Development Guide.

DiscuzSession ds = DiscuzSessionHelper. GetSession ();
TopicCreateResponse CTL = ds. CreateTopic (uid, title, fid, message, tags, type_id );

4. Get user comments using the official API

DiscuzSession ds = DiscuzSessionHelper. GetSession ();
TopicGetRencentRepliesResponse trr = ds. GetRecentReplies (fid, tid, page_size, page_index );

5. Post New comments. Here is the main reason why the API was not fully used at the beginning. The API needs to jump continuously to verify the user. After studying the source code, I wrote my own comment function, mainly calling the official stored procedure "dnt_createpost1". due to too many parameters, I will not write code here, mainly to assign values to parameters, user data can be obtained based on the method used to obtain user information. You can also download the data dictionary from the official website to determine the Parameter Function.

 

Here is a copy of ASP. NET integration Discuz! The NT package collects all the integrated resources I have collected.

Is http://nt.discuz.net/showtopic-140682.html#599637

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.