Skip to content

Instantly share code, notes, and snippets.

@bastianallgeier
Created July 13, 2015 13:34
Show Gist options
  • Select an option

  • Save bastianallgeier/66a5876fde8e5bf03c11 to your computer and use it in GitHub Desktop.

Select an option

Save bastianallgeier/66a5876fde8e5bf03c11 to your computer and use it in GitHub Desktop.
<?php
c::set('routes', array(
array(
'pattern' => 'post',
'method' => 'POST',
'action' => function() {
if(get('token') != 'your-very-long-auth-token') {
return response::error('Unauthorized');
}
try {
$note = page('notes')->children()->create(date('Ymdhis'), 'note', array(
'text' => get('content')
));
return response::success('The new note has been created', array(
'url' => $note->url()
));
} catch(Exception $e) {
return response::error($e->getMessage());
}
}
)
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment