doumigu9594 2016-08-20 04:26
浏览 274
已采纳

Laravel REST API调用返回状态为200的虚拟数据

I am working on making mobile application backend apis. The api I am working on now is just getting user information. I am testing the api with Postman app.

When I call the api on the postman, it returns JSON data successfully, but sometimes it returns dummy data for same api call. And when I try again, it returns correct JSON data.

I am attaching two screens. Here is the issue: enter image description here

Below shows correct response:

enter image description here

I am using Laravel5.1 and OAuth2 authentication module(lucadegasperi/oauth2-server-laravel) from Github. Server is hosted on Bluehost.

Here is laravel code:

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index($id = null)
    {
        if($id == null) {
            $my_id = Authorizer::getResourceOwnerId();
            return User::find($my_id);
        }
        else
            return User::find($id);
    }

I am struggling with this issue for a week and please help me. Thanks in advance.

  • 写回答

2条回答 默认 最新

  • dongzhihong3940 2016-08-20 05:18
    关注

    It looks like it has something to do with Incapsula. I don't know if this is something you setup, or if it is setup by your host, but the traffic to your website is going through Incapsula. Some of your POSTMAN requests are getting through fine, but some of them are being blocked by Incapsula, probably because they look like someone trying to scrape your site.

    If you have control over this, you may want to whitelist your local IP while developing and testing.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 MATLAB卫星二体模型仿真
  • ¥15 怎么让数码管亮的同时让led执行流水灯代码
  • ¥20 SAP HANA SQL Script 。如何判断字段值包含某个字符串
  • ¥85 cmd批处理参数如果含有双引号,该如何传入?
  • ¥15 fx2n系列plc的自控成型机模拟
  • ¥15 时间序列LSTM模型归回预测代码问题
  • ¥50 使用CUDA如何高效的做并行化处理,是否可以多个分段同时进行匹配计算处理?目前数据传输速度有些慢,如何提高速度,使用gdrcopy是否可行?请给出具体意见。
  • ¥15 基于STM32,电机驱动模块为L298N,四路运放电磁传感器,三轮智能小车电磁组电磁循迹(两个电机,一个万向轮),如何通过环岛的原理及完整代码
  • ¥20 机器学习或深度学习问题?困扰了我一个世纪,晚来天欲雪,能饮一杯无?
  • ¥15 c语言数据结构高铁订票系统