Skip to content
Mostey edited this page Sep 7, 2014 · 1 revision

Addressing and Requirements

When interacting with sections (subforums), you should be aware of how they are identified and addressed. Every section got an unique identifier consisting of a simple unsigned number. For example, this unique identifier is used for creating threads in this specific section so if it isn't provided, the vBulletin system does not know which section it should assign this thread to.

Another unique identifier is the URL address name which is displayed in the browser addressbar. For example, if the section Main is displayed in the browser, the address bar will contain something similar to this: http://www.elitepvpers.com/forum/main/. main being the url address name that is needed for updating sections and fetching their threads. This is also important since the library is building the link with the URL address name to request the information.

We already have some sections built straight into the section class as static properties. You can, for example, retrieve the built-in sections accessing their properties as follows:

uint id = Section.Main.ID;

This will store the ID of the main section into the variable id.

If you want to reference a section that is not covered as own property in the Section class, you can create your own object:

var grandTheftAutoSection = new Section(672, "grand-theft-auto");


Retrieving Threads

The Section class contains the function Threads which can be used to query all threads contained by the specified section with different parameters.

...
foreach (var thread in Section.Main.Threads(session, 10))
    dataGridView1.Rows.Add(thread.ID, thread.Title, thread.PreviewContent, thread.Sticked, thread.Closed, thread.Creator.Name + "(" + thread.Creator.ID + ")", thread.Replies, thread.Views);

The code above will retrieve all threads within the first 10 pages and displays them in a DataGridView. If you don't specify the start index (i.e. the page from where to start requesting), the first page (1) will be used. By default, 1 page is queried and retrieved.

Note: The higher the page count, the longer it takes to retrieve all threads.

Updating Section information

Sections are holding different information such as the count of threads stored and the amount of pages. Announcements are also part of the Section class which will be updated on executing the Section.Update function.

For example, if we want to retrieve all announcements of the Main section that were created by user John Dread, we would write the following code:

Section.Main.Update(session);
var announcementsByJohn = new List<Section.Announcement>(Section.Main.Announcements.Where(announcement => announcement.Sender.ID == 517481)); 
Clone this wiki locally