如何将Laravel 5连接到Android?

时间:2016-04-24 08:07:06

标签: php android laravel

我对如何将Laravel作为Web服务连接到Android有点好奇。我目前正在连接Native php到android。这是一个成功的联系。 但遗憾的是我制作了我的laravel代码,但一直都失败了。我想我需要一个关于如何为Android制作laravel web服务的答案

以下是我的Android代码:

package skyvity.belisini.Controller;

import android.util.Log;
import android.widget.Toast;import org.apache.http.NameValuePair;import org.json.JSONArray;import org.json.JSONException;import org.json.JSONObject;import java.util.ArrayList;import java.util.List;importskyvity.belisini.Config.JSONParser;

public class ItemController {

//Listing Home
public  static JSONArray jsonArray= null;
public static ArrayList<String> Item = new ArrayList<String>();
public static ArrayList<String> desc = new ArrayList<String>();
public static ArrayList<String> price = new ArrayList<String>();
public static ArrayList<String> seller = new ArrayList<String>();
public static ArrayList<String> picture = new ArrayList<String>();

public static void list_item(){
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    JSONParser jsonParser= new JSONParser();
jsonParser.request(JSONParser.base_url+"json",params);
    if(object!=null){
        Log.v("Proceed", "Succeed");
        Log.v(JSONParser.base_url+"json",params.toString());
    }
    else{
        Log.v("Proceed", "Not Succeed");
        object = jsonParser.request(JSONParser.base_url+"assets/test/item_list.php",params);
        Log.v(JSONParser.base_url+"assets/test/item_list.php",params.toString());
    }
    try {
        if(object.getJSONArray("data")==null){
            Log.v("not Failed in here","NULL JSON");
        }
        jsonArray = object.getJSONArray("data");
        Log.v("not Failed in here",jsonArray.toString());
        for(int i=0;i<jsonArray.length();i++){
            Log.v("notFailed here","Lol");
            JSONObject jsonObject = jsonArray.getJSONObject(i);
            Item.add(jsonObject.getString("nama_item"));
            desc.add(jsonObject.getString("description"));
            price.add(jsonObject.getString("price"));
            seller.add(jsonObject.getString("seller"));
            picture.add(jsonObject.getString("picture"));
        }
    }catch (JSONException e){
        e.printStackTrace();
        Log.v("LOL" , e.toString());
    }
}
}

我对Laravel Side网络服务很好奇。我目前的laravel回归

Json返回html

如果要查找日志,我可能知道怎么知道吗?

这是我的jsons

{
status: 1,
message: "getting data",
data: [
{
nama_item: "Verix",
price: 1,
seller: "admin",
picture: "assets/img/sale/phpAF87.tmp"
},
{
nama_item: "Jasa ISP",
price: 500000,
seller: "wilztan",
picture: "assets/img/sale/php1D23.tmp"
},
{
nama_item: "Kevin William",
price: 1000000,
seller: "wilztan",
picture: "assets/img/sale/php1EC.tmp"
}
]
}

0 个答案:

没有答案