Friday, 27 September 2013

How to use a php restful api-centric design internal instead of with http request

How to use a php restful api-centric design internal instead of with http
request

Lang: php
Servers: Amazon e2/lamp
Database: MySQL
I am wanting to create a php restful api-centric web application/website.
Where as I have the data/api that gets called from my front end code.
Besides making HTTP/curl request calls each time I load a page, what can I
do for internal API calls using frameworks like slim.
I'm not sure of a way to include the api for internal use in my front end
code and still keep it apart.
My thoughts was something like this:
"example.com/api/story/todays-weather/"
pulls in the json formatted story with a http request with curl or Ajax
But instead could I do something like:
require("/api/internal.php");
$uri = "/story/todays-weather/";
$call = api::getStory($uri);
$result = json_decode($call);
.....
I'm a headed in the right direction or am I way off. =/
The api and front code are on the same cloud box and I am planing on using
memcached for the api.

No comments:

Post a Comment