java - OKHTTP -- Posting user-input data, retrieving JSON response to determine success -
i've been thinking in how this. i've read trough okhttp documentation, have idea on how handle i'm not entirely sure.
i'll have user submit 3 fields ( username, password, database ). i'll have php file uploaded host accepts post data. ( it's pure php, no html. accepts data posted page. )
once values have been submitted, i'll perform check. credentials found? return/echo json array ( success/ failure ). check if array key " success " equals either 1 || 0. if 1, show toast user has been logged in successfully.
now, question. logic correct? if not, how it? have tips me? examples?
to send "authorization" in http requests have set header 403.
header('http/1.0 403 forbidden'); echo 'you forbidden!';
but when send json via php page, using 'generator' make easy, simple json php.
include('includes/json.php'); $json = new json(); $json->add('status', '403'); $json->add('message', 'you forbidden!'); $json->send();
update : headers if want send "home made" json :
header('cache-control: no-cache, must-revalidate'); header('expires: mon, 26 jul 1997 05:00:00 gmt'); header('content-type: application/json');
edit :
there slim framework, didn't try it, seems efficient! simple json php name says, create json & send it, not use make use of routes @ all.
Comments
Post a Comment