来自 Webhook 的 Parse.com after_save 产生无效的 json

Parse.com after_save from Webhook produces invalid json

我在 Parse.com 错误日志中看到以下错误:

E2015-09-28T12:40:37.531Z]vWEB after_save 为用户 gI8UxW2JNa 的 MPPChatRoom 触发:

输入:{"object":{"counter":0,"createdAt":"2015-09-18T12:35:28.195Z","description":"client at Milton","lastMessage":"VGVzdA==\n","lastUser":{"__type":"Pointer","className":"_User","objectId":"Eoi7gcQ4Rs"},"memberCount":2,"members":["Eoi7gcQ4Rs","gI8UxW2JNa"],"mppfile":{"__type":"Pointer","className":"MPPFile","objectId":"3tZWUNHXlf"},"objectId":"jZS5dhQPna","owner": {"__type":"Pointer","className":"_User","objectId":"Eoi7gcQ4Rs"},"roomId":"88b17cd0-63cd-40c7 -8b7a-3b6d356768be","status":1,"title":"Tom Grey","updatedAction":{"__type":"Date","iso":"2015-09-18T12:59:19.995Z"},"updatedAt":"2015-09-28T12:40:37.528Z","user":{"__type" :"Pointer","className":"_User","objectId":"gI8UxW2JNa"}}}

结果:无效JSON

我正在摸不着头脑,因为我在 class 上没有任何自定义 after_save 云代码函数。然而,我确实有一个 after_save 的网络钩子 class:

Webhook 类型:保存后, Class: MPPChatRoom, URL: https:// 我的域名 /messagePush/parseMessagePush.php

因为是after_save所以我无法控制输入,而且看上面的输入,我也看不出JSON有什么问题。上面的json复制粘贴到https://jsonformatter.curiousconcept.com/

才有效

有人能帮忙吗?

编辑 1: 我是 webhooks 的新手,我不是 PHP 开发人员,所以我假设 PHP 产生了错误,而不是 Parse?这是初始代码:

include "../includes/config.inc.php";
    $sql_object = new sql_class('parseMessagePush.php');
    ob_start();
    echo "<pre>";
    print_r($_POST);
    print_r($_GET);
    print_r($_SERVER);
    print_r(json_decode(file_get_contents('php://input'), true));
    $dataLog = json_decode(file_get_contents('php://input'), true);

我现在认为其中一个 json_decode 调用导致异常。虽然我不明白为什么 Parse 会发送无效 json。

我认为通过回显 parseMessagePush.php 文件中的 JSON 成功数据解决了这个问题:

header("Content-Type: application/json");
$sucessData = array('status_code' => '200',"status_message" =>'success');
echo json_encode($sucessData);