想要使用 Parse Rest 在 CodeIgniter 中管理 mongodb 用户 API

Want to manage mongoldb user on CodeIgniter using Parse Rest API

数据库:Mongodb 后端框架:CodeIgniter

想要从后端管理默认用户 table。我正在使用 ParseRestAPI 但众所周知 Mongodb 不允许在没有会话的情况下更新用户。那么有什么方法可以管理 App 创建的用户和 delete/create 新用户。

是的,您可以使用 Parse Rest API

例如删除用户: 使用 DELETE http 动词并调用类似的东西:

注意:您需要传递Session Token或Master Key

 curl -X DELETE \
  -H "X-Parse-Application-Id: YOURAPPID" \
  -H "X-Parse-REST-API-Key: YOURAPIKEY" \
  -H "X-Parse-Session-Token: SESSIONTOKEN" \
  -H "X-Parse-Master-Key: YOURMASTERKEY" \
  https://api.example.com/1/users/<objectId>

在php中你可以这样写:

$ch = curl_init('https://api.example.com/1/users/<objectId>');                                                                      
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");                                                                     

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
    'Content-Type: application/json',                                                                                
    'X-Parse-Application-Id: YOURAPPID',
    'X-Parse-REST-API-Key: YOURAPIKEY', 
    'X-Parse-Master-Key: YOURMASTERKEY'                                                                 
);                                                                                                                   

$result = curl_exec($ch);

要创建用户调用 API(例如我使用 curl)

        curl -X POST \
        -H "X-Parse-Application-Id: YOUAPPID" \
        -H "X-Parse-REST-API-Key: YOURAPIKEY" \
        -H "Content-Type: application/json" \
        -d '{ "objectId": "", "updatedAt": "", "createdAt": "", "name": "John Doe", "pass": "toto42" }' \
        https://api.example.com/1/classes/User/