Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 通过HttpClient Android发布时的Laravel Rest身份验证_Php_Android_Rest_Laravel 4 - Fatal编程技术网

Php 通过HttpClient Android发布时的Laravel Rest身份验证

Php 通过HttpClient Android发布时的Laravel Rest身份验证,php,android,rest,laravel-4,Php,Android,Rest,Laravel 4,当我通过android HttpClient发布时,我如何过滤laravel rest应用程序、经过身份验证的用户ID和正确的密码? 我试图找到最好的方法,但没有得到最好的样品 这是我的代码: public static int LogExceptionError(final ExceptionLog exceptionLog) { final HttpResponse[] response = new HttpResponse[1]; new Thread(n

当我通过android HttpClient发布时,我如何过滤laravel rest应用程序、经过身份验证的用户ID和正确的密码? 我试图找到最好的方法,但没有得到最好的样品

这是我的代码:

public static int LogExceptionError(final ExceptionLog exceptionLog) {

        final HttpResponse[] response = new HttpResponse[1];
        new Thread(new Runnable() {
            public void run() {
                // Create a new HttpClient and Post Header
                HttpClient httpClient = new DefaultHttpClient();
                HttpPost httpPost = new HttpPost(AndroidHelperUtility.getBaseUrl("exceptionlog/create", AndroidHelperUtility.IS_DEBUG_MODE));
                try {

                    Gson gson = new Gson();
                    String jsonString = gson.toJson(exceptionLog);

                    JSONObject jsonObject = new JSONObject();
                    jsonObject = new JSONObject(jsonString);

                    JSONArray jsonArray = new JSONArray();
                    jsonArray.put(jsonObject);

                    // Post the data:
                    httpPost.setHeader("json", jsonObject.toString());
                    httpPost.getParams().setParameter("jsonpost", jsonArray);

                    // Execute HTTP Post Request
                    System.out.print(jsonObject);
                    HttpResponse httpResponseponse = httpClient.execute(httpPost);
                } catch (JSONException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
        }).start();

        if (response[0] != null) {
            return 1;
        } else {
            return 0;
        }
    }
拉威尔控制器:

public function postCreate() {
        $json = $_SERVER['HTTP_JSON'];
        $data = json_decode($json);  
        $object = ExceptionLogService::create($data);
        return Response::json($object);

    }
服务类别:

class ExceptionLogService extends BaseService {

    public static function create($data) {
        $object = array(
            "refNumber" => $data->refNumber,
            "source" => $data->source,
            "userName" => $data->userName,
            "description" => $data->description
        );
        ExceptionLogRepository::create($object);
        return $object;
    }
最后,我发现: