MyBB Community Forums

Full Version: Publish posts with attachments from a desktop software
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I wanna code a Java application that publishes posts with attachments. Is this possible? Does MyBB have a publicly available API?
There is not an API at this moment but you can do it with a POST request. Although that's quite complicated. You'll first need to login by doing a HTTP request in Java, retrieve the cookie if a login is successful and then do a POST request to the newthread.php page with the mybb cookies in the header. You also need to have the post key for that user. The post key consists of the user's login key, salt and registration date, all concatenated and hashed with MD5:
return md5($mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate']);
(2011-06-06, 02:47 PM)Aries-Belgium Wrote: [ -> ]There is not an API at this moment but you can do it with a POST request. Although that's quite complicated. You'll first need to login by doing a HTTP request in Java, retrieve the cookie if a login is successful and then do a POST request to the newthread.php page with the mybb cookies in the header. You also need to have the post key for that user. The post key consists of the user's login key, salt and registration date, all concatenated and hashed with MD5:
return md5($mybb->user['loginkey'].$mybb->user['salt'].$mybb->user['regdate']);

Thanks a lot for that. This is exactly what I want do, but are there any tutorials or examples so that I can have an idea about what I'm going to do?
(2011-06-06, 02:56 PM)AmrH Wrote: [ -> ]Thanks a lot for that. This is exactly what I want do, but are there any tutorials or examples so that I can have an idea about what I'm going to do?

I only know the basics of Java but I can describe you how the process could look like:
- do a POST request to the member.php with the following post data:
action=do_login&username=USERNAME&password=PASSWORD&remember=yes
Fetch the Set-Cookie headers from the HEAD of the response and parse them.
- do another GET request to newreply.php?tid=THREAD_ID and make sure you put the cookies you just retrieved from the previous request into the request header. Now fetch the value of the my_post_key input field from the html
- do a POST request to to newreply.php and with the following post data:
action=do_newreply&tid=THREAD_ID&subject=SUBJECT&message=MESSAGE
and then somehow put the file content in the attachment field. I found this by doing a quick search: http://www.hiteshagrawal.com/java/http-p...nt-in-java