View Full Version : Adding threads via .NET application
Labelsoft
07-09-2009, 08:29 AM
Hello,
Does anyone on this board have experience with programmatically adding threads (and ofcourse their first post) in vBulletin's forum via a .NET application?
I have looked at the API's (in PHP) which vBulletin made available and it seems that I would need: "class_dm_threadpost.php", if I would be programming in PHP. The problem now is that I need to insert threads via a .NET application I'm developing.
I've scrolled through this API and it's 36 pages long, which indicates to me that inserting a thread is not as easy as it would seem. Namely inserting a record in the 'thread' table and a record in the 'post' table and voila. Or is it this simple?
Is there anyone that can point me into the right direction? Thank you very much in advance for answering.
Dismounted
07-09-2009, 09:42 AM
It is mainly SQL queries, to add the thread, the post, and update some caches. It is not as "simple" as some people think.
What I suggest is maybe creating your own PHP file that when called upon, creates a thread. This would allow you to use vBulletin classes/methods, and thus, reducing the chance of things breaking in the future.
Labelsoft
07-09-2009, 11:54 AM
First off, thank you very much for replying so soon.
I am a complete PHP novice, so in order to fully understand what you mean, can I ask some more questions?
1) What do you exactly mean with making my own PHP file? I'm sure with some time I could create some PHP script (with some help from you *looks hopefull* :o ) that would make using vBulletin's classes/methods easier. But if I have that file, what do I do with it? I don't know of a way to call such a PHP file from .NET code.
2) I'm afraid I'll have to do it the hard way. I'll have to add a thread + post + update some caches manually from .NET code. If I go that way, could you help me a bit? For example... What are those caches you are talking about? And which ones need an update?
By the way... Just to make my intentions absolutely clear. My .NET app's soul purpose is to just shoot a thread (+ post) into vBulletin's MySQL DB. After that, the app is basically done. It doens't need to know anything about it, or manage it further. Would perhaps make the process a bit simpler? :D
Thnx in advance for your help!
GameDude
07-09-2009, 12:12 PM
I'm not sure able .NET, but I posted a PHP class a couple of days ago to make threads, posts, and send PMs. It has all the proper SQL queries in it. Here is the link to the thread. (https://vborg.vbsupport.ru/showthread.php?t=218051)
Labelsoft
07-10-2009, 08:52 AM
Thank you very much GameDude. I've scanned the code and I certainly think it'll help me construct .NET code which will do the same as your PHP class. Just two quick questions though:
1) vBulletin's DB doesn't auto increment the technical ID's (I see you adding 1 to the id's in the code)?
2) You don't need the column 'DateLine' (you insert post and thread without dateline)?
Thnx again for the code and thnx in advance for answering.
Dismounted
07-10-2009, 09:48 AM
vBulletin's DB doesn't auto increment the technical ID's (I see you adding 1 to the id's in the code)?
The primary keys in all tables with one defined are auto incremented, and a value should NEVER be inserted by hand. MySQL does the work.
You don't need the column 'DateLine' (you insert post and thread without dateline)?
The dateline must be generated and inserted, it is not automatically inserted by MySQL.
Labelsoft
07-10-2009, 10:01 AM
@Dismounted:
1) Yeah, I figured that would be a bit strange. But have you seen Gamedude's code? He claims it works. If this is true, his code could never work.
2) Ok, how does one generate a Dateline then? What is it exactly? It looks a bit like an UNIX timestamp.
3) Last question, could you please take a quick peek at Gamedude's code and tell me if that code works? 'Cause then I'm going to stop immediatly converting his PHP code to .NET code.
Thank you in advance.
Dismounted
07-10-2009, 11:18 AM
Yeah, I figured that would be a bit strange. But have you seen Gamedude's code? He claims it works. If this is true, his code could never work.
MySQL doesn't stop you from entering arbitrary values, his code will probably cause issues down the track though (e.g. duplicate IDs, etc.).
Ok, how does one generate a Dateline then? What is it exactly? It looks a bit like an UNIX timestamp.
It is exactly what you guessed - a simple Unix timestamp.
Last question, could you please take a quick peek at Gamedude's code and tell me if that code works? 'Cause then I'm going to stop immediatly converting his PHP code to .NET code.
The code probably works, but is it the best method? Probably not. See the function "build_new_post()", it contains what you want - the "method" of generating a post/thread.
Labelsoft
07-10-2009, 12:57 PM
@Dismounted
Ok, I've found a way to call PHP "method". It envolves wrapping PHP with WSDL (NuSOAP makes this easy) and referencing it as a service in Visual Studio. I found this information here: http://www.phpeveryday.com/articles/Web-Services-How-PHP-Kiss-VB-NET-Part-2--P68.html
Can you tell me where I can find the "build_new_post()" function?
I will post my progress here, so in the future you can reference people to this topic if they have a similar problem.
p.s.: I suppose you guys haven't already wrapped PHP files with WSDL? *looks hopefull*
Dismounted
07-10-2009, 12:59 PM
Can you tell me where I can find the "build_new_post()" function?
/includes/functions_newpost.php
Also see newthread.php or newpost.php for an implementation example.
Labelsoft
07-15-2009, 10:00 AM
Sorry for the late reply.
I have been trying to call functions_newpost.php through WSDL for the past two days. It is not going that well. There is something wrong that I am not able to fix. Zend Studio does generate WSDL properly from vBulletin's PHP file using the comments you guys provided above your functions (excellent... well done). But referencing the service in visual studio gives me unexpected errors in the app.config file, which I am not able to fix. There are too many variables that I have to take in account. So I had to abandon this idea.
So, unfortunatly I feel obligated to duplicate what 'build_new_post' does in .NET code. In order to do that I registered all the tables in vBulletin's DB which get updated after posting a thread on the forum. And I've got a few questions about that:
1) table 'adminlog'; what is this table used for? Is is updated necessarily by posting a thread on the forum?
2) table 'cronlog'; what is this table used for? Is is updated necessarily by posting a thread on the forum?
3) table 'moderatorlog'; what is this table used for? Is is updated necessarily by posting a thread on the forum?
4) table 'phrase'; what is this table used for? Is is updated necessarily by posting a thread on the forum?
5) table 'pmtext'; what is this table used for? Is is updated necessarily by posting a thread on the forum?
6) table 'post' (well this one is obvious... so no questions);
7) table 'posthash'; what is this table used for? Is is updated necessarily by posting a thread on the forum?
8) table 'postlog'; what is this table used for? Is is updated necessarily by posting a thread on the forum?
9) table 'rsslog'; what is this table used for? Is is updated necessarily by posting a thread on the forum?
10) table 'template'; what is this table used for? Is is updated necessarily by posting a thread on the forum?
11) table 'thread' (well this one is obvious... so no questions);
12) table 'threadread' (well this one is obvious... so no questions);
13) table 'threadviews' (well this one is obvious... so no questions);
Thank you very much in advance for answering.
Labelsoft
07-21-2009, 09:03 AM
Seeing as everybody knows exactly what they are doing we have gone with RSS feeds.
The .NET application now creates RSS files. Goes without saying that this works like a charm (as long as you don't need very complicated things like polls and such).
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.