Im designing a php API, I give to my user a php file (core.php) to add on their servers. And then to use it they just have to include_once('api/core.php'). Inside core.php I need to create some functions that just parse json files from my main server.
Lets say they need a complete user list, so they will have to do something like:
include_once('api/core.php');
print_r(myApi_list('user','all'));
Inside core.php the function will be something like:
function myApi_list($pa, $pb) {
if($pa == 'user') {
//here will be a code that call my server
return resp;
}
//more stuf
}
And of course there will be another script on my server that will handle the sql querys and security stuff. My problem is, what will be the best way to call my server from core.php, should I use file_get_contents? and just tell my server script to answer with maybe a json file (and then core.php just parse that)? Or should I user cUrl? Since this is an API i will prefer to use the module that is more likely to be active by default on a php sever.
What do you think is the best approach on this situation?