Skip to content

Instantly share code, notes, and snippets.

@ikwattro
Created June 25, 2012 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikwattro/2988040 to your computer and use it in GitHub Desktop.
Save ikwattro/2988040 to your computer and use it in GitHub Desktop.
Login form description in API
<?php
public function logsinAction()
{
$hypermedia = 'application/vnd.com.doggiiz.api+json';
$data = array(
'message' => 'Welcome to the login page',
'self' => 'http://localhost/~ikwattro/devapp/app_dev.php/front/logsin',
'_links' => array(
'home' => array(
'href' => 'http://localhost/~ikwattro/devapp/app_dev.php/front/logsin',
'desc' => 'Return to home page'
)
),
'_actions' => array(
'login' => array(
'method' => 'POST',
'action' => 'http://localhost/~ikwattro/devapp/app_dev.php/front/logsin/verify',
'enctype' => null,
'fields' => array(
'username' => array(
'type' => 'text',
'required' => true,
'name' => 'doggiiz_form_login_username',
'label' => 'username'
),
'password' => array(
'type' => 'password',
'required' => true,
'name' => 'doggiiz_form_login_password',
'label' => 'password'
),
'firstname' => array(
'type' => 'text',
'required' => false,
'name' => 'doggiiz_form_login_firstname',
'label' => 'firstname'
),
'csrf' => array(
'type' => 'hidden',
'value' => 'fdsFDQSf56',
'required' => true,
'name' => 'doggiiz_form_login_csrf',
)
)
)
)
);
$json_data = json_encode($data);
$response = new Response($json_data, 200);
$response->headers->set('Content-Type', $hypermedia);
return $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment