【问题标题】:How to process json requests in lumen 5.8如何在 lumen 5.8 中处理 json 请求
【发布时间】:2020-03-14 09:27:21
【问题描述】:

我有json登录如下:

{
"email":"mypersonaldata@gmail.com"
"password":"12345"
}

我可以使用$content = $request->getContent(); 在控制器上捕获 json 我希望用

验证 json
        //validate incoming request 
        $this->validate($request, [
            'email' => 'required|string',
            'password' => 'required|string',
        ]);

        $credentials = $request->only(['email', 'password']);

        if (! $token = Auth::attempt($credentials)) {
            return response()->json(['message' => 'Unauthorized'], 401);
        }

请帮助我如何做到这一点,非常感谢你

【问题讨论】:

    标签: php json lumen


    【解决方案1】:

    你好朋友你可以看看你会很容易理解的文档 https://laravel.com/docs/5.7/authentication 参考。

    【讨论】:

      猜你喜欢
      • 2011-05-02
      • 2011-03-05
      • 2018-04-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-20
      • 1970-01-01
      • 2013-03-18
      相关资源
      最近更新 更多