Support the ongoing development of →
posted 9 years ago
Last updated 2 years ago.

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?

Last updated 2 years ago.
$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..

Last updated 2 years ago.

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.

Last updated 2 years ago.

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?

Last updated 2 years ago.

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 ( is a good source).

A lot to learn!! Good luck.

Last updated 2 years ago.

Thank you for replying. I'll read more documentation about laravel. :)

Last updated 2 years ago.

oroalej : have you solved the problem ? i have same problem as you.

Last updated 2 years ago.

@oroalej and @erdimas

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

Last updated 8 years ago.

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!


Your banner here too?

alex1991 alex1991 Joined 19 Jun 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.