Hi,
Using OTDS how to get Bearer Token for API Authentication. And, what is expiry time limit for token.
Hi, hope this can give you a hint... :-)
<?php
/*
Proof of concept script
Do not use on production
*/
// HTTPFUL Library
error_reporting(-1);
ini_set('display_errors', 'On');
include('httpful.phar');
// Initial header
$header = array(
'Content-Type' => 'application/json',
);
// OAuth and Extream paths
$oauth_path = 'https://.../otdsws/v1/authentication/credentials';
$document_path = 'https://.../v1/documents/';
// Get Token/OTDSTicket
$auth = \Httpful\Request::post($oauth_path)
->addHeaders($header)
->body(json_encode(array(
'user_name' => '',
'password' => '',
)))
->send();
// Update header with authentication ticket
$header['OTDSTicket'] = $auth->body->ticket;
// Search for a document
$document = \Httpful\Request::get($document_path.
'?where_typeid=archiveobject'.
'&where_filter=["EQ","**Field GUID**","**Field value**"]'.
'&guid_format=false')
// Get the first document we find in the search
$firstDocument = $document->body->data[0];
// Get the related file
$documentData = \Httpful\Request::get($document_path . $firstDocument->id . '/content')
// Dump the test file
file_put_contents('test_file.pdf', $documentData);
?>
Really helpful, you are my hero!!