Postman的GET请求没有显示JSON输出

时间:2018-06-12 00:56:57

标签: php api http get httprequest

我正在使用PHP REST API,我做了这个功能:

 function getNotifications($request) {
     require_once 'db.php';
     $emp = json_decode($request->getBody());
     $id = $request->getAttribute("id");
     $sql = "select * FROM notifications WHERE userid= :userid";

     try {
         $db = getConnection();
         $stmt = $db->prepare($sql);
         $stmt->bindParam("userid", $id);
         $stmt->execute();
         $wines = $stmt->fetch(PDO::FETCH_OBJ);
         $db = null;

         return json_encode($wines);
     } catch(PDOException $e) {
         echo '{"error":{"text":'. $e->getMessage() .'}}';
     }
}

当我尝试回显wines变量echo wines->message;时,它正在运行,因此问题不在于查询。
问题是当我尝试在没有回声的情况下调用API时,没有任何显示,甚至没有消息说我没有结果。

0 个答案:

没有答案