Ausgaben
Da wir uns noch nicht genau mit der XML-RPC Technologie von Drupal und Services Modul auskennen, bilden wir den ersten release durch eigene XML Definitionen.
Diese Dateien legen wir ins Hauptverzeichnis von Drupal ab.
Authentifizierung Prüfung: checkauth.php
Wir wünschen eine Schnittstelle welche uns den angemeldeter benutzer Name liefert.
<?php
// $Id$
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
Header('Expire: Mon, 26 Jul 1997 05:00:00 GMT');
Header('Last-Modified: '. gmdate("D, d M Y H:i:s") . " GMT");
Header('Cache-Control: no-store, no-cache, must-revalidate,post-check=0, pre-check=0", false');
Header('Pragma: no-cache');
Header('Content-Type: text/xml');
$out = '<?xml version="1.0" encoding="iso-8859-1"?>';
$_out .= "<results>\\n";
// Menu status constants are integers; page content is a string.
if ($user->uid) {
$result = $user->name;
} else {
$result = 0;
}
$_out .= ' <response title="'.$result.'">' . "</response>\n";
$_out .= "</results>\n";
echo $_out;
?>Wenn der Benutzer an der Drupal Instanz angemeldet ist, wird folgende Antwort zurückgegeben.
1 2 3 | <results> <response title="foxfabi"/> </results> |
Taxonomy Daten: tagdata.php
Wir wünschen eine Schnittstelle welche uns den Schlagwörter Block als XML liefert.
<?php
// $Id$
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
# simple security .. check for drupal uid
if ($user->uid) {
$vid = 1; // Set the vid to the vocabulary id of the vocabulary you wish to list the terms from
$vocs[] = $vid;
$tags = tagadelic_get_weighted_tags($vocs, variable_get('tagadelic_levels', 12), variable_get('tagadelic_page_amount', '60'));
$tags = tagadelic_sort_tags($tags);
foreach ($tags as $tag) {
if ($tag->number_of_posts> 0) {
$tag->name .= " (".$tag->number_of_posts.")";
$outtag[] = $tag;
}
}
$outtag= @array_slice($outtag, 0, 9);
foreach ($outtag as $k=>$showtag) {
$_output .= ' <tag title="'.$showtag->name.'" id="'.$k.'">' . "</tag>\n";
}
}
Header('Expire: Mon, 26 Jul 1997 05:00:00 GMT');
Header('Last-Modified: '. gmdate("D, d M Y H:i:s") . " GMT");
Header('Cache-Control: no-store, no-cache, must-revalidate,post-check=0, pre-check=0", false');
Header('Pragma: no-cache');
Header('Content-Type: text/xml');
$out = '<?xml version="1.0" encoding="iso-8859-1"?>';
$_out .= "<tags>\n";
$_out .= $_output;
$_out .= "</tags>\n";
echo $_out;
?>Die XML Antwort beihaltet die Kategorien welche im Block Schlagwörter ausgegeben werden:
1 2 3 4 56 7 8 9 1011 | <tags> <tag title="freak (1)" id="0"/> <tag title="fun (1)" id="1"/> <tag title="cms (1)" id="2"/> <tag title="Cinema 4D (1)" id="3"/> <tag title="3D Design (1)" id="4"/> <tag title="Grafik (1)" id="5"/> <tag title="internet (1)" id="6"/> <tag title="Webdeveloper (1)" id="7"/> <tag title="sicherheit (1)" id="8"/></tags> |
Gruppen: