MyBB Community Forums

Full Version: Substitutes for an API
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I would like to be able to make new threads and posts programatically from outside myBB. Since 2.0 isn't ready yet, what are my options?

Can I just include the relevant myBB files and call the appropriate functions?

Is it possible to use an http POST or GET to create threads and posts?

I saw this:
http://phpdave.com/MyBBIntegrator/

Has anyone used it? Does it work with the current version of myBB?
Simulating the HTTP POST request would probably be my recommendation.
Not really an API, but perhaps the simplest approach and least prone to error.
(2013-01-11, 10:35 PM)Yumi Wrote: [ -> ]Simulating the HTTP POST request would probably be my recommendation.
Not really an API, but perhaps the simplest approach and least prone to error.

Is that method documented anywhere? I did a packet dump of a real POST request and I'm trying to duplicate it with a POST utility. It looks like there are a bunch of security things to keep people from doing just that. I'm getting an error that says Authorization code mismatch.
I'm not getting anywhere with a POST. What about writing to the database directly?
(2013-01-14, 07:53 PM)jstotz Wrote: [ -> ]I'm not getting anywhere with a POST. What about writing to the database directly?

that is what the integrator you linked to does. it simply includes the required mybb files and uses that code to validate and push data around.
(2013-01-14, 07:55 PM)pavemen Wrote: [ -> ]that is what the integrator you linked to does. it simply includes the required mybb files and uses that code to validate and push data around.

That's the next thing I'll try. One unknown is if it works with the current version of myBB. Also, there is no example code for creating a post.
(2013-01-14, 08:26 PM)jstotz Wrote: [ -> ]
(2013-01-14, 07:55 PM)pavemen Wrote: [ -> ]that is what the integrator you linked to does. it simply includes the required mybb files and uses that code to validate and push data around.

That's the next thing I'll try. One unknown is if it works with the current version of myBB. Also, there is no example code for creating a post.

there is very little change in the core code that the integrator works with, if anything the way some variables are passed may have changed but no functions have been massively overhauled or deprecated.

i would assume that there are no examples based on the fact that it uses the default MyBB code for processing data so you just need to look at how MyBB submits info from a form to know what content is needed.

i think there is an assumption of a minimum level of knowledge of MyBB and PHP required if you want to get into full lintegration
I tried the integrator. There are some examples on the web site. It looks like the first thing that needs to be done is to log in. There is an example for that, but it doesn't seem to work. So I'm stuck there.

There is a note that says: Note: The login might not work on your site when using the MyBB Integrator. You have to make sure that the cookies are accessable for the MyBB Integrator. Therefore, double check your cookie domain!

I don't know what that means, and I don't even know if it applies to me. I'm not using a web site, I'm just running a php script from the command line.
what is the url you are trying to connect to mybb from?
what is the url to your mybb installation?
what are the three cookie settings in the ACP > Config > General Settings?
(2013-01-15, 03:44 PM)pavemen Wrote: [ -> ]what is the url you are trying to connect to mybb from?
what is the url to your mybb installation?
what are the three cookie settings in the ACP > Config > General Settings?

I have myBB running on an internal server. It's not accessible from outside. The url would be something like http://internaladdress/mybb MyBB itself works fine in a browser from other computers on our network.

At first, I was running my script from a browser on the same network. http://internaladdress/mybb/myscript.php

Then I tried just running the script in php from the command line.
php -f myscript.php

The results are the same either way. Unfortunately, the myBB intergator login function just returns true or false. It doesn't say why the login failed. I'm going to try to add some debugging code to see if I can figure out why it's failing.

Cookie domain: blank
Cookie path: /mybb/
It recommends the full directory path, so if they mean an absolute path then I should change it to /var/www/mybb/
Cookie prefix: blank

It looks like the myBB routine that checks for an existing user is saying that the user I'm trying to log in doesn't exist.