Created
July 13, 2015 13:34
-
-
Save bastianallgeier/66a5876fde8e5bf03c11 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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