root/trunk/dotnode-api_rest.php

Revision 27, 1.0 KB (checked in by alexx, 7 years ago)
  • Add support for .node album in Meta album (not usefull for dotnode.com user, but good for other "Open .node" installation that want to import dotnode.com album)
  • Add REST api to access .node Album (must be extented later with other module of .node)
  • Add forgotten icons for meta album
  • Add dPics scripts to automagicaly resize requested image with size put in his url (<dpics script>/500x400/<file_path>.jpg => give you <file_path>.jpg in 500x400)
Line 
1<?
2include_once('../../includes/includes.inc.php');
3include_once('XML/Tree.php');
4
5$method_filename = API_REST_METHODPATH.'/'.str_replace('.', '/', $_REQUEST['method']).'.rest.php';
6
7if(file_exists($method_filename)) {
8    include_once('DB.php');
9    $db =& DB::connect($dsn);
10    if (DB::isError($db))
11        $error = array(3, 'DB connection error');
12    else
13    {
14        $db->setFetchMode(DB_FETCHMODE_ASSOC);
15
16        if($db->getOne('SELECT COUNT(id) FROM user WHERE id=?', array($_REQUEST['api_key'])) == 1) {
17            $xml =& new XML_Tree();
18            $rst_node =& $xml->addRoot('rsp', null, array('stat'=>'ok'));
19
20            include $method_filename;
21        } else {
22            $error = array(69, 'Bad API Key');
23        }
24       
25        $db->disconnect();
26    }
27} else {
28    $error = array(99, 'method '.$_REQUEST['method'].' not found');
29}
30
31if(is_array($error)) {
32    $xml =& new XML_Tree();
33    $rst_node =& $xml->addRoot('rst', null, array('stat'=>'fail'));
34    $rst_node->addChild('err', null, array('code'=>$error[0], 'msg'=>$error[1]));
35}
36
37header('Content-type: text/xml; charset=UTF-8');
38
39$xml->dump();
40
41?>
Note: See TracBrowser for help on using the browser.