This library is a PHP wrapper of Mindmeister API, the REST API so far.
It's goal is to provide an object approach to query Mindmeister and handling
easily the authentication part.
I've initially started this library to deeply embed Mindmeister into WordPress blogs. That's why it's not PHP 5.3 and thus, there is no namespace usage.
- PHP 5.2+
- PHP Curl package (apt://php5-curl)
First, head to your account and register an API key for your application.
The API key and the shared secret are mandatory to use this library.
The authentication process is not very clear, as described in the documentation.
For the desktop process, here is the detailed walkthrough:
- Retrieve a frob (random string) through
mm.auth.getFrob
method - Redirect the user to the Auth URL
- Retrieve the auth token through
mm.auth.getToken
method - Permanently store the token
Then, for all following API calls, use the auth token for the authenticated methods.
The library automatically append this parameter if needed, in order to avoid thinking about that detail.
The mm.auth.getToken
will successfully reply only if the Auth URL has been visited.
Otherwise, it will fail.
What the library does not do (yet), is the authentication workflow.
require 'lib/Mindmeister/REST/Factory.php';
$mm = Mindmeister_REST_Factory::initialize(API_KEY, SHARED_SECRET);
//lists all maps if authenticated
if (!$mm->isAuthenticated())
{
/*
* 1) Retrieving frob
*/
$request = $mm->request('mm.auth.getFrob');
$frob = $request->dispatch()->getValue('frob');
/*
* 2) Visiting Mindmeister Auth URL
*/
$url = $mm->getConfiguration()->getAuthTokenUrl($frob);
fread(STDIN); //or other mechanism to pause execution while waiting user to visit the URL
/*
* 3) Retrieving Auth Token
*/
$request = $mm->request('mm.auth.getToken');
$request->setParameter('frob', $frob);
$auth_token = $request->dispatch()->getValue('token');
/*
* 4) Persisting Auth Token
* Second parameter is for persisting (stateless otherwise)
*/
$mm->getConfiguration()->setAuthToken($auth_token, true);
//$mm->isAuthenticated() === true
}
require 'lib/Mindmeister/REST/Factory.php';
$mm = Mindmeister_REST_Factory::initialize(API_KEY, SHARED_SECRET);
//lists all maps if authenticated
if ($mm->isAuthenticated())
{
$request = $mm->request('mm.maps.getList');
$response = $request->dispatch();
foreach ($response->getContent()->maps as $map)
{
$attributes = $map->attributes();
//process stuff here
//$attributes->title, $attributes->description etc.
}
}
Expected parameters and results can be found in Mindmeister API documentation.
- mm.auth.checkToken
- mm.auth.getFrob
- mm.auth.getToken
- mm.maps.getList
- mm.maps.getMap
- mm.maps.getPublicList
- mm.maps.getPublicMap
- Provide an API for response, to avoid cycling through SimpleXMLElements
- Provide an Auth Token storage backend
- Provide a validation mechanism before dispatching a request
- Implementing Exceptions
- Handling error codes (and mix them with Exceptions mechanism)
- Implement ArrayAccess interface for Response
- Unit Testing