diff --git a/htdocs/application/controllers/api.php b/htdocs/application/controllers/api.php new file mode 100755 index 0000000..3ecee9a --- /dev/null +++ b/htdocs/application/controllers/api.php @@ -0,0 +1,56 @@ +languages->get_languages(); + $languages = array_keys($languages); + $languages = implode(', ', $languages); + $data['languages'] = $languages; + $this->load->view('api_help', $data); + } + + function create() + { + $this->load->model('pastes'); + + if (!$this->input->post('text')) + { + $data['data'] = array( + 'error' => 'missing paste text', + ); + $this->load->view('view/api', $data); + } + else + { + + if (!$this->input->post('lang')) + { + $_POST['lang'] = 'text'; + } + $_POST['code'] = $this->input->post('text'); + $paste_url = $this->pastes->createPaste(); + $data['data'] = array( + 'url' => base_url() . $paste_url, + ); + $this->load->view('view/api', $data); + } + } +} diff --git a/htdocs/application/views/api_help.php b/htdocs/application/views/api_help.php new file mode 100755 index 0000000..8a6c33c --- /dev/null +++ b/htdocs/application/views/api_help.php @@ -0,0 +1,61 @@ +load->view("defaults/header");?> + +
+

API

+

Create pastes from the commandline

+ +

API URL

+

+ +

Return values

+

+ On success, the API returns the paste URL in JSON format: {"url":""}
+ On error, the API returns the error message in JSON format: {"error":"missing paste text"} +

+ +

POST parameters

+

 

+ + text=[your paste text] +

The paste content. Required.

+ + name=[name] +

The author's name.

+ + private=1 +

Make paste private.

+ + lang=[language] +

+ Use alternative syntax highlighting.
+ Possible values: +

+ + expire=[minutes] +

Set paste expiration.

+ + reply=[pasteid] +

Reply to existing paste.

+ +

Examples

+

 

+ +

Create paste

+ curl -d text='this is my text' +

Create a paste with the text 'this is my text'.

+ +

Create paste from a file

+ curl -d private=1 -d name=Herbert --data-urlencode text@/etc/passwd +

Create a private paste with the author 'Herbert' and the contents of '/etc/passwd'.

+ +

Create paste from a php file

+ curl -d lang=php --data-urlencode text@main.php +

Create a paste with PHP syntax highlighting.

+ +

Get paste ;-)

+ curl +

Display paste.

+ +
+ +load->view("defaults/footer");?> diff --git a/htdocs/application/views/defaults/header.php b/htdocs/application/views/defaults/header.php index 38ffb3e..015d5bd 100755 --- a/htdocs/application/views/defaults/header.php +++ b/htdocs/application/views/defaults/header.php @@ -35,6 +35,7 @@ $this->carabiner->display('css'); uri->segment(1)?>
  • href="" title="Create A New Paste">Create
  • uri->segment(2) != "options"){ echo 'class="active"'; }?> href="" title="Recent Pastes">Recent
  • +
  • href="" title="API">API
  • href="" title="About">About
  • diff --git a/htdocs/application/views/view/api.php b/htdocs/application/views/view/api.php new file mode 100755 index 0000000..07689db --- /dev/null +++ b/htdocs/application/views/view/api.php @@ -0,0 +1,3 @@ +