I am a PHP developer and need to implement web services for mobile application developers to share data such as posts, likes, etc.
What is the best way to implement such web services? Is there a standard for stuff like this?
Currently I do output JSON with messages, contents and so on.
My main problem with app developers is about error messages. I suggest to return an array with error codes and messages to show:
$result = array(
'status' => false, // because registration failed
// if registration succeed then would be true
'errors' => array(
array(
'code' => '1',
'message' => 'Password is not strong enough!',
),
array(
'code' => '2',
'message' => 'Password and password confirmation do not match!',
),
array(
'code' => '3',
'message' => 'This email address has been used!',
),
),
);
But they suggest to return all error messages as an string and they would only use the status parameter and if it was false then will show message, something like this:
$result = array(
'status' => false,
'message' => 'Password is not strong enough!' . PHP_EOL .
'Password and password confirmation do not match!' . PHP_EOL .
'This email address has been used!',
);
Thanks in advance