RESTful usually refers to an HTTP Method based API.
You issue HTTP GET to (who thought it) GET information,
HTTP POST to CREATE new data,
HTTP PUT is usually used to change existing data (or to create new data with a specific identifier like the songID)
HTTP DELETE to (again surprising) delete information.
That's basically how all modern APIs like Twitter, Facebook etc. work.
They just include an advanced authentication and permission scheme on top of that.
The data returned is usually either JSON or XML.
With that said, there are Frameworks in many programming languages that enable one to easily build a webservice based on a MySQL database.
Of course one could still build such a thing from scratch, but that's only really useful if you just need a single page without authentication.
(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
<?php
// Define path to application directory
defined('APP_PATH') || define('APP_PATH', realpath(dirname(__FILE__)));
// Ensure common is on include_path
set_include_path(implode(PATH_SEPARATOR, array(realpath(APP_PATH . '/library'), '.')));
// Make a shortcut to DIRECTORY_SEPARATOR
define('DS', DIRECTORY_SEPARATOR);
// The Singleton Database class
require_once('Common/Database.php');
$db = Database::getInstance(APP_PATH.DS.'config'.DS.'dbconfig.xml.php');
$db->setFetchMode(Zend_Db::FETCH_OBJ);
// show only the 20 most recent results
$select = $db->select()->from('historylist')->order('id DESC')->limit(0, 20);
$stmt = $db->query($select);
$result = $stmt->fetchAll();
header('Content-Type: application/json');
echo json_encode($result);
?>
Place this in the root of SAMPHPWeb so it can use your dbconfig.xml.php and the Zend DB stuff.