Closed thenickless closed 3 weeks ago
zu a) "Input Authentifizierung"
A) Basic Authentication (Benutzername und Passwort)
$response = wp_remote_get( 'https://example.com/api/resource', array(
'headers' => array(
'Authorization' => 'Basic ' . base64_encode( 'username:password' )
)
));
if ( is_wp_error( $response ) ) {
// Fehlerbehandlung
} else {
$body = wp_remote_retrieve_body( $response );
// Verarbeiten Sie die Antwort
}
B) Bearer Token (App-ID oder API-Schlüssel)
$response = wp_remote_get( 'https://example.com/api/resource', array(
'headers' => array(
'Authorization' => 'Bearer YOUR_APP_ID_OR_API_KEY'
)
));
if ( is_wp_error( $response ) ) {
// Fehlerbehandlung
} else {
$body = wp_remote_retrieve_body( $response );
// Verarbeiten Sie die Antwort
}
C) URL-Parameter (App-ID)
$url = 'https://example.com/api/resource?app_id=YOUR_APP_ID';
$response = wp_remote_get( $url );
if ( is_wp_error( $response ) ) {
// Fehlerbehandlung
} else {
$body = wp_remote_retrieve_body( $response );
// Verarbeiten Sie die Antwort
}
D) Custom Headers
$response = wp_remote_get( 'https://example.com/api/resource', array(
'headers' => array(
'Custom-Header' => 'CustomHeaderValue'
)
));
if ( is_wp_error( $response ) ) {
// Fehlerbehandlung
} else {
$body = wp_remote_retrieve_body( $response );
// Verarbeiten Sie die Antwort
}
Zu aufwendig. Simpler umgesetzt als array in CustomerDomains.php mit derzeit zwei Datenquellen: https://statistiken.rrze.fau.de/webauftritte/domains//analyse/domain-analyse-18.json https://statistiken.rrze.fau.de/webauftritte/domains//analyse/domain-analyse-1.json
=> done in 1.7.3
a) settings.php : Tabelle mit
Ist: hardcoded Soll: einstellbar machen in Settings. Grund: bequem weitere Datenquellen reinzunehmen + nutzbar für andere, nicht nur Uni-Netz
b) CustomerDomain.php grast alle Einträge ab. Ist: 1 endpoint ist hardcoded Soll: options auslesen und loopen