I'm trying to make an API for my web site using PHP, since the site is coded in PHP, so the developers can get information using AJAX Requests to my server, but how I can make this?
Update: Any sites where I can get examples?
I'm trying to make an API for my web site using PHP, since the site is coded in PHP, so the developers can get information using AJAX Requests to my server, but how I can make this?
Update: Any sites where I can get examples?
Like any regular form processing. The difference is that you typically return JSON instead of HTML when it is an API to be used with AJAX requests:
<?php
header("Content-Type: application/json");
print json_encode(array("sum" => $_GET["a"] + $_GET["b"]));
That would be a simple addition API. Which is obviously a silly example. It very much depends on what you want to accomplish with your API, and what data your site actually handles.