Extending the API

Permalink Browser Info Environment
Hi 5Jack!

I love what you've done here, this will really be great and useful in some projects.

One point though is the extendibility of the API. I would love if you could extend the API in a way that you can currently extend the Events in concrete5. Now if I want to add new API methods, I'll need to modify the API controller to do that.

So, just one idea that you could define the API methods something like this:
JacksAPI::setApi('page', 'MyOwnApiController', 'page_api', __FILE__);


So, something similar that you currently do with events? The only difference might be that one API action can have only ONE function that provides the information.

Then in the api/controller.php you could check whether the called action has any API method, something like this:
$array = JacksAPI::launch($_GET['action']);
if ($array) {
   $this->set('array',$json->encode($array));
} else {
   $e = JacksAPI::getErrors();
}



What do you think?


Best,
Antti / Mainio

Type: Discussion
Status: New
Mainio
View Replies:
12345j replied on at Permalink Reply
12345j
this seems like a really good idea. I'll take a stab at implementing it, but it might take a while.
Mainio replied on at Permalink Reply
Mainio
Ok, great to hear!

Yeah, I'm not saying I would need it NOW but I know I will need a feature as such in the future.

Another point that you might want to keep in mind is that people also might want to "override" the current API actions, so that should also be considered when building an architecture like that.

Antti

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.