0

我在 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": "指针","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

我对此感到头疼,因为该类上没有任何自定义 after_save 云代码功能。但是,我确实为该类的 after_save 提供了一个 webhook:

Webhook 类型:afterSave,类:MPPChatRoom,URL:https:// my domain /messagePush/parseMessagePush.php

由于它是 after_save 我无法控制输入,并且查看上面的输入,我也看不出 JSON 有什么问题。当我将上面的 json 复制并粘贴到https://jsonformatter.curiousconcept.com/时,它是有效的

任何人都可以帮忙吗?

编辑 1:我是 webhook 的新手,我不是 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。

4

1 回答 1

0

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

header("Content-Type: application/json");
$sucessData = array('status_code' => '200',"status_message" =>'success');
echo json_encode($sucessData);
于 2015-09-30T00:18:16.017 回答