You'll need to explain more about your set up before anyone can help.
Show us your code for Laravel and also how are you passing the json to Android. How are you parsing in on your device?
$query = mysql_query("SELECT * FROM employee WHERE username = '$username'") or die(mysql_error());
$query = mysql_fetch_array($query);
$response["success"] = 1;
$response["id"] = $query["id"];
$response["username"] = $query["username"];
$response["password"] = $query["password"];
$response["afirst_name"] = $query["afirst_name"];
$response["alast_name"] = $query["alast_name"];
$data = Response::json($response)->header('Content-Type', 'application/json');
echo $data->getContent();
This is my code for passing json to android..
Are you then visiting it in a browser in Android? I'm not 100% but the Android browser might not be able to parse json in that way. You may need a middleware solution like AngularJS to help out.
Is this code in a view? A route closure? Or just a file in public? Is it part of a function? Are you using the MVC pattern?
If you can explain a little more about how you have set things up, someone should be able to help a little more.
There are also better ways to set your app up to serve your Android app - And whatever else you need.
I just put this on my route file, like Route::get('/url'/ , function(){ and the codes }. if i put this code in my public files, how can my friend access this??Can you suggest a better way to do this?
Yeah, I'd suggest doing some reading on building an API. There is too much to explain here and a lot to learn. It really depends on what you are trying to build.
Take a look at the Laravel docs. This will teach you a lot.
What you have done isn't really the best approach. I'd suggest that you do some tutorials (http://laracasts.com is a good source).
A lot to learn!! Good luck.
Thank you for replying. I'll read more documentation about laravel. :)
oroalej : have you solved the problem ? i have same problem as you.
You both have to use POSTMAN to test your webservice.
If you are getting response in json format then i will successfully works for you.
You can check your json at http://json.parser.online.fr/beta/
It happens the same for me, i've been surfing the internet to solve this problem, but sadly till now. i haven't found out the question may i know more if anyone find out the solutions?
anyway. from Json in My Browser seems okkay. just like the native Php one. and when it uses PostMan it qualify it as no error json.
Still Confuses on This problem
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community