I made this "REST" API for SMF that will work with SMF 2.x that might be helpful to someone.
The reason REST is in quotes is it's not a true RESTful API but it will allow you to use the API and SSI functions on your SMF installation from a different domain. It will also let you create posts, send pm's and it is easy to extend to do other things...
How to use:
Download the two attachments here, the client and server. Extract the server package and upload it somewhere on your SMF forum domain.
In the api folder, open the SmfRestServer.php file and on line 47 specify your SECRET_KEY. Make it secure!! A long string that nobody will guess. Save it and upload it to the api folder.
Open the file SmfRestClient.php and on line 52, set the path to your api folder, the one you just uploaded.
Upload the file SmfRestClient.php somewhere, it doesn't need to be on the same domain as the api server folder.
Now you are ready to call the API. You do this by first including the file SmfRestClient.php :
require_once('SmfRestClient.php');
then you will instantiate the SmfRestClient object like this:
$secretKey = 'sdgefgbdbdvberger4564trgdfgdfvcvv';
$api = new SmfRestClient($secretKey);
Be sure you set the $secretKey variable to be your unique secret key that you set above.
Now you can use the API functions by calling them like this:
$api->login_user('andre');
You can get the results/output of your API call like this:
$result = $api->get_userInfo();
the results will be a stdClass Object by default.
If you instantiate the API client with the parameter 'raw' like this:
$api = new SmfRestClient($secretKey, 'raw');
you will get the output as an array instead.
