【问题标题】:Parse REST API set ACL to an object将 REST API 集 ACL 解析为对象
【发布时间】:2015-10-02 17:17:44
【问题描述】:

我正在尝试为通过 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


    【解决方案1】:

    希望对你有帮助。

    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 },
            "*" : {}
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2018-12-30
      • 1970-01-01
      • 2017-01-24
      • 1970-01-01
      • 1970-01-01
      • 2014-08-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多