More help to use REST API
This commit is contained in:
parent
0cde6ad98f
commit
e8bd1357f3
@ -150,12 +150,30 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM
|
||||
print load_fiche_titre($langs->trans("ApiSetup"),$linkback,'title_setup');
|
||||
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
|
||||
// Show message
|
||||
print '<br>';
|
||||
$message='';
|
||||
$url='<a href="'.$urlwithroot.'/api/index.php/login?login='.urlencode($user->login).'&password=yourpassword" target="_blank">'.$urlwithroot.'/api/index.php/login?login='.urlencode($user->login).'&password=yourpassword</a>';
|
||||
$message.=$langs->trans("UrlToGetKeyToUseAPIs").':<br>';
|
||||
$message.=img_picto('','object_globe.png').' '.$url;
|
||||
print $message;
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
|
||||
print $langs->trans("ListOfAvailableAPIs").':<br>';
|
||||
foreach($listofapis['v1'] as $key => $val)
|
||||
{
|
||||
if ($key == 'login') continue;
|
||||
if ($key)
|
||||
{
|
||||
//print $key.' - '.$val['classname'].' - '.$val['fullpath']." - ".DOL_MAIN_URL_ROOT.'/api/index.php/'.strtolower(preg_replace('/Api$/','',$val['classname']))."/xxx<br>\n";
|
||||
$url=DOL_MAIN_URL_ROOT.'/api/index.php/'.$key;
|
||||
$url=$urlwithroot.'/api/index.php/'.$key;
|
||||
$url.='?api_key=token';
|
||||
print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
|
||||
|
||||
}
|
||||
|
||||
@ -141,6 +141,8 @@ foreach ($modulesdir as $dir)
|
||||
|
||||
// TODO If not found, redirect to explorer
|
||||
|
||||
|
||||
// Call API (we suppose we found it)
|
||||
$api->r->handle();
|
||||
|
||||
|
||||
|
||||
@ -1740,3 +1740,5 @@ AddOtherPagesOrServices=Add other pages or services
|
||||
AddModels=Add document or numbering templates
|
||||
AddSubstitutions=Add keys substitutions
|
||||
DetectionNotPossible=Detection not possible
|
||||
UrlToGetKeyToUseAPIs=Url to get token to use API (once token has been received it is saved on database user table and will be checked on each future access)
|
||||
ListOfAvailableAPIs=List of available APIs
|
||||
Loading…
Reference in New Issue
Block a user