diff --git a/API.md b/API.md index 5c37bab..fc5610f 100644 --- a/API.md +++ b/API.md @@ -13,48 +13,6 @@ To use the API you can use Ox.App if you use Ox.js, or look at [pandora_client]( ### Examples -#### PHP -``` -url = $url; - } - public function _request($action, $data) { - $content = array( - 'action' => $action, - 'data' => json_encode($data) - ); - $options = array( - 'http' => array( - 'header' => "Content-type: application/x-www-form-urlencoded\r\n", - 'method' => 'POST', - 'content' => http_build_query($content), - ), - ); - $context = stream_context_create($options); - $result = json_decode(file_get_contents($this->url, false, $context)); - return $result; - } -} -l -$api = new API('http://archive.arabdigitalexpression.org/api/'); - -$result = $api->_request('find', array( - "query"=>array( - "conditions"=>array(array("key"=>"*", "value"=>"paris", "operator"=>'=')) - ), - "keys"=>array("title", 'id'), - "range"=> array(0, 10), - "sort"=>array(array("key"=>"title", "operator"=>"+")) -)); - -var_dump($result); - -``` - #### JavaScript ``` @@ -159,4 +117,47 @@ for i in api.find({'query': { if i['groups'] != groups: print id api.edit({'id': i['id'], 'groups': groups}) -``` \ No newline at end of file +``` + + +#### PHP +``` +url = $url; + } + public function _request($action, $data) { + $content = array( + 'action' => $action, + 'data' => json_encode($data) + ); + $options = array( + 'http' => array( + 'header' => "Content-type: application/x-www-form-urlencoded\r\n", + 'method' => 'POST', + 'content' => http_build_query($content), + ), + ); + $context = stream_context_create($options); + $result = json_decode(file_get_contents($this->url, false, $context)); + return $result; + } +} +l +$api = new API('http://archive.arabdigitalexpression.org/api/'); + +$result = $api->_request('find', array( + "query"=>array( + "conditions"=>array(array("key"=>"*", "value"=>"paris", "operator"=>'=')) + ), + "keys"=>array("title", 'id'), + "range"=> array(0, 10), + "sort"=>array(array("key"=>"title", "operator"=>"+")) +)); + +var_dump($result); + +```