/smfapi

REST API for Simple Machines Forum (SMF) 2.0

Primary LanguagePHP

REST API for Simple Machines Forum (SMF) 2.0

Build Status

Note: This is a fork of the SMF REST API by Andre Nickatina. Our intention is to upgrade and maintain the API.

Use this to integrate your SMF version 2.0 forum with 3rd party software If you need help using this script or integrating your forum with other software, feel free to contact andre@r2bconcepts.com

Installation using composer

Add the following to your composer.json file:

"require": 
{
	"erazorbg/smfapi": "dev-master"
},
"repositories": 
[
	{
	    "type": "vcs",
	    "url" : "https://github.com/erazorbg/smfapi.git"
	}
]

Update dependencies:

php composer update

Configuration

  • Upload the content of the Server folder to your SMF installation folder
  • (optional) Change the path to your Settings.php
//path/to/your/smf/api/folder/smf_2_api.php

// manually add the location of your Settings.php here
if (!isset($settings_path) || empty($settings_path)) {
    // specify the settings path here if it's not in smf root and you want to speed things up
    // $settings_path = $_SERVER['DOCUMENT_ROOT'] . /path/to/Settings.php
    if (isset($settings_path) && !file_exists($settings_path)) {
        unset($settings_path);
    }
}
  • (optional) In case you use nginx as webserver configure it to emulate the .htaccess
Satisfy Any

RewriteEngine on

RewriteRule .* index.php [L]
 
  • Set an API key in the index.php file:
define ('SECRET_KEY', 'Put your secret key here'); // set your secret key here

Hint: You may generate a key under Linux with a bash command like:

dd if=/dev/urandom bs=8 count=8 | openssl base64 | tr -d '\n'

Usage

<?php

$client = new SmfApi\Client\SmfRestClient($apiServerUrl, $secretKey);