User:Guerric > Access the API with Plug

Access the API with Plug

Table of contents
No headers
$dreamServer = 'http://YOURWIKI:DREAMPORT';
$dreamServer = 'http://YOURWIKI/@api';
$dekiApi = 'deki';
// end plug configuration
$username = 'admin';
$password = 'password'; // i hope your password isn't password
// end user config

$Plug = new Plug($dreamServer);
$Plug = $Plug->At($dekiApi);

$authResult = $Plug->At('users', 'authenticate')->WithCredentials($username, $password)->Get();
$authToken = $authResult['body'];

$Plug = $Plug->With('authtoken', $authToken);
// now subsequent requests will be accessed with the authenticated user's persmissions

$result = $Plug->At('something', 'something')->Get();

   

Tag page
You must login to post a comment.
Powered by MindTouch Deki v.8.08.2