RRZE-Webteam / rrze-shorturl

WordPress-Plugin to enable a shorturl redirection service run on two servers (WP + PHP-only)
https://www.shorturl.rrze.fau.de
GNU General Public License v3.0
0 stars 1 forks source link

Neuer Bereich in Settings: Datenquellen #88

Closed thenickless closed 3 weeks ago

thenickless commented 1 month ago

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

thenickless commented 1 month 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
}
thenickless commented 3 weeks ago

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