解析 REST API 将 ACL 设置为对象

问题描述 投票:0回答:2

我正在尝试为通过 Parse REST API 创建的对象设置 ACL 权限。我希望它只有公共读取权限。只有服务器可以创建或修改类中的对象。我阅读了有关如何设置 ACL 权限的解析 REST 文档。

当我运行以下命令时:

$InputData = array('votes' => 1, 'ACL' => array('*' => array('read' => true, 'write' => false)), 'user' => array('__type' => 'Pointer', 'className' => '_User', 'objectId' => $objectId));

$rest = curl_init();
curl_setopt($rest,CURLOPT_URL,$url);
curl_setopt($rest,CURLOPT_PORT,443);
curl_setopt($rest,CURLOPT_POST,1);
curl_setopt($rest,CURLOPT_POSTFIELDS, json_encode($InputData));
curl_setopt($rest,CURLOPT_HTTPHEADER, 
    array("X-Parse-Application-Id: " . $appId,
        "X-Parse-Master-Key: " . $restKey,
        "Content-Type: application/json"));

我得到:

{"code":123,"error":"Invalid acl {\"*\":{\"read\":false,\"write\":false}}"} 1

我的代码有什么问题,特别是 ACL 部分?救命!

rest curl parse-platform
2个回答
3
投票

希望有帮助。

curl -X POST \
-H "Content-Type: application/json" \
-H "X-Parse-Application-Id: xxxxxxxxxxxxxxx" \
-H "X-Parse-REST-API-Key: xxxxxxxxxxxxx" \
-H "X-Parse-Session-Token: xxxxxxxxxxxxxx" \
-d "{\"name\":\"MyName\", \"ACL\": {\"ErKLiQfj8Q\" : { \"read\": true, \"write\": true }, \"*\" : {}}}" \
https://api.parse.com/1/classes/Tasks

JSON 对象

{
  "name":"MyName",
  "ACL":
    {
        "ErKLiQfj8Q" : { "read": true, "write": true },
        "*" : {}
    }
}

0
投票

您正在谈论什么应用程序上的 ACL?鸽舍?

© www.soinside.com 2019 - 2024. All rights reserved.