[IPB 2.1] API

by Matt Mecham on July 20, 2005

A party inside?
A persons IQ?

Nope. Application Programming Interface. This exciting term encapsulates the ability to interfere with a program without having intimate knowledge of the program’s code. Good idea, I say.

With this in mind, I’ve started work on IPB 2.1’s API. Now, fundamentally IPB has core classes, of which an API layer is wrapped around then and then another layer wrapped around that called ‘HTTP-API’. The HTTP-API wrapper will allow one to fire off commands via the wonders of POST or GET. When correctly configured, you’ll be able to update your member’s signature with a command as insanely easy as “httpapi.php?api=members&-save-signature=hax&id=32&apikey=hilariously
longkeyhere’. This further abstracts one from the realities of getting one’s hands dirty with nasty old PHP code.

However, before we get all carried away with that, we first need a good solid API structure which interfaces with the IPS classes without re-creating too much code. Our utopian fantasy would involve lots of naked women, I mean, it would involve being able to write a whole suite of API classes and then write a framework called IPB that uses them. However, this is still a relatively distant dream simply because the average forum system is one big bad-ass hack. Programming theory and the reality of cramming 350 accounts on a P4 web server don’t often run along the same lines. The average forum system (and indeed, the average web application) takes advantage of several short-cuts to reduce the number of loaded classes and queries. This isn’t ideal but the having your program banned is less desirable.

So, I’ve had to suffer a little duplication. Originally I had planned to make the Posts API directly load class_post.php functions but class_post.php is only really set up to deal with the current logged in member (something that will be addressed in IPB 3.0) and thus not useable. Fortunately, I’ve been able to make use of class_post in other areas, such as topic rebuilding, forum rebuilding, stats rebuilding, topic tracking and forum tracking meaning the only real duplication we have is with the actual data insertion. Good enough until I go through the code during IPB 3.0’s development cycle.

Here’s how easy it is to add a reply to a post:

$api = new api_topics_and_posts();
$api->set_author_by_name(’matt’);
$api->set_post_content(”Hello World! :D ”);
$api->set_topic_id( 100 );
$api->create_new_reply();

And topics…

$api->set_author_by_name(’matt’);
$api->set_post_content(”Hello World! :D ”);
$api->set_forum_id( 10 );
$api->set_topic_title(’Hello World’);
$api->create_new_topic();

{ 1 trackback }

Pete's Blog
November 14, 2005 at 10:38 pm

{ 18 comments… read them below or add one }

1 Danny July 20, 2005 at 5:31 pm

Wow, that looks really easy (adding topics). Are you going straight to 3.0 after 2.1?

2 Myr July 20, 2005 at 7:09 pm

Great! I’m hoping this simplicity will also apply to checking profiles for information, checking to see if a member’s logged in on the cookie, etc.

3 Anonymous July 20, 2005 at 7:34 pm

Could ye or someone else explain this in simipler terms. I’d probley have to watch a few movies of what your talkin aboout. o and yes I did read the ENTIRE blog entry.

4 Anonymous July 20, 2005 at 7:34 pm

nm. I think I get it. DOH!

5 Will78 July 20, 2005 at 7:56 pm

hey nice going Matt damn seems like every new feature gets more interesting

6 Antony July 20, 2005 at 8:47 pm

So its going to be like the IPB SDK… Exactly how many things will we be able to do?

7 ipbmods.com July 21, 2005 at 2:52 pm

wow,

this is one of the feature which iam waiting since 1.0 :D .

i will use this httpapi for a modification which i plan since a long time, and matt, it will use your new component and module system (yes, you don´t have make this system for nothing ;) .

regards
bernhard

8 Dan July 21, 2005 at 4:21 pm

I’m already working on things using the components system. I can’t wait to work with the API / HTTP-API system, though. :D

9 Kennedy July 24, 2005 at 10:22 am

Cool. :)

10 The Jedi July 25, 2005 at 10:24 am

Cool. Editing a topic/post will be possible too ? A topic creation will return the topic ID too ?

Excellent thing however :)

11 Alahmnat August 3, 2005 at 8:43 am

Matt, I think I might have to kiss you…

*gets ready to throw out most of his hacked-in functionality in favor of API stuff*

12 TheBrain0110 September 14, 2005 at 9:41 pm

Great. Really Great.

Oh, and perhaps I shouldn’t ask how those trackbacks got there?

13 Glen September 22, 2005 at 5:51 am

Sounds cool but a bit over my head….Sounds like you can do really cool stuff with this API but this will be a bit tough for us non-programmers… :) Maybe an “API for Dummies” post in the forum is needed :)

14 Pita November 12, 2005 at 12:42 pm

Looks good, but more API functionality would be useful :)

15 История Египта April 14, 2007 at 3:06 pm

this is one of the feature which iam waiting since 1.0 :D .

i will use this httpapi for a modification which i plan since a long time, and matt, it will use your new component and module system.info

16 George Sorof April 19, 2007 at 5:20 pm

I’m already working on things using the components system. I can’t wait to work with the API / HTTP-API system, though. :D
good!

17 статьи April 19, 2007 at 5:21 pm

hey nice going Matt damn seems like every new feature gets more interesting

18 MajaSaalis June 22, 2009 at 3:35 pm

Tere!

Suitsetan juba 8 aastat, nььd aga otsustasin, et tuleb loobuda sellest! Aitab! Kas kellegil on kogemus, kuidas on kergem seda teha?
Tean mitmeid variante-
tabletid, ehk toidulisandid
plaastrid
nдtsud
!!! Raamat !!! ( Allen Carr vist oli )

Kas on teada veel variante?

Tдnud!

Leave a Comment

Previous post: Busy Week

Next post: [IPB 2.1] Template Set Differences