Social Icons

twitterfacebookgoogle pluslinkedinrss feedemail


Friday, November 29, 2013

PHP library for calling WSO2 API manager publisher

My need is to create an application that manages the creation of API from a single central point (a PHP site).

The WSO2 API manager has some interesting REST API that can be used to create programmatically an API.

To manage these API better I've developed (still in development) a library that calls the API manager, manage errors and wrap the whole up.

If you need it here is the link to github.

The usage of the library is pretty straightforward:

You create the class passing the address of the API manager (and optionally the user and password, it default to the default admin/admin)

$wso2api = new Wso2API("");

Than create the two array with the parameters to pass for the creation:

$create_api_post = array('name'=>'WikipediaAPI',
                         'description'=>'If you want to monitor a MediaWiki installation',
                         'bizOwner'=>'Luca Gioppo',

$create_api_resources = array (array('resourceMethod'=>'GET',

In the end you can just call the create method that can accept also the autopublish flag that manage the settings of the API in PUBLISHED state in one call (usually API are in CREATED state and you have to set it to PUBLISH as a second step.

$ret = $wso2api->create_api($create_api_post, $create_api_resources, $autopublish = true);

0 commenti: