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

时间:2015-09-28 15:32:11

标签: php json parse-platform webhooks after-save

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

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

输入:{“object”:{“counter”:0,“createdAt”:“2015-09-18T12:35:28.195Z”,“description”:“Milton的客户”,“lastMessage”:“VGVzdA == \ n”个, “lastUser”:{ “__类型”: “指针”, “类名”: “_用户”, “对象ID”: “Eoi7gcQ4Rs”}, “MEMBERCOUNT”:2 “成员”:[ “Eoi7gcQ4Rs” “gI8UxW2JNa”], “mppfile”:{ “__类型”: “指针”, “类名”: “mPPFile”, “对象ID”: “3tZWUNHXlf”}, “对象ID”: “jZS5dhQPna”, “所有者”:{” __type “:” 指针”, “类名”: “_用户”, “对象ID”: “Eoi7gcQ4Rs”}, “roomId”: “88b17cd0-63cd-40c7-8b7a-3b6d356768be”, “状态”:1, “标题”: “Tom Gray”,“updatedAction”:{“__ type”:“Date”,“iso”:“2015-09-18T12:59:19.995Z”},“updatedAt”:“2015-09-28T12:40:37.528 Z”, “用户”:{ “__类型”: “指针”, “类名”: “_用户”, “对象ID”: “gI8UxW2JNa”}}}

结果:JSON无效

由于我在该课程中没有任何自定义的After_save云代码功能,因此我对此感到不安。但我确实在该类上有一个关于after_save的webhook:

Webhook类型:afterSave, 课程:MPPChatRoom, 网址:https:// 我的域名 /messagePush/parseMessagePush.php

因为它是一个after_save我无法控制输入,看着上面的输入,我也看不出JSON有什么问题。当我将其复制并粘贴到https://jsonformatter.curiousconcept.com/

时,上面的json有效

有人可以帮忙吗?

编辑1: 我是webhooks的新手,我不是PHP开发人员所以我假设P​​HP正在产生错误,而不是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。

1 个答案:

答案 0 :(得分:0)

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

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