Created
November 26, 2018 11:29
-
-
Save gnh1201/c3ec1a7eec66cf33fba60e9e17395af6 to your computer and use it in GitHub Desktop.
Directus 7 with ReasonableFramework: Get token and Data migration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// (How to) Get DIrectus 7 CMS token by ReasonableFramework | |
// step by step | |
// 1. git clone https://github.com/gnh1201/reasonableframework | |
// 2. edit /storage/config/database.ini (if you want data migrate to directus) | |
// 3. fill your email address and password into this example | |
// 4. copy edited example to /route directory | |
// 5. connect to http://[your-web-url]/?route=migrate | |
loadHelper("webpagetool"); | |
// Authenticate | |
$url = "https://directus.local/api/_/auth/authenticate"; | |
$response = get_web_json($url, "jsondata", array( | |
"email" => "[email protected]", | |
"password" => "password" | |
)); | |
$token = $response->data->token; | |
echo "token: " . $token . "<br>"; | |
// create item | |
$url = "https://directus.local/api/_/items/testcollection"; | |
$response = get_web_json($url, "jsondata", array( | |
"headers" => array( | |
"Authorization" => "Bearer " . $token | |
), | |
"data" => array( | |
"name" => "hello", | |
"category" => "world" | |
) | |
)); | |
var_dump($response); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment