1. Go to this page and download the library: Download wp-media/fleet-bridge library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wp-media / fleet-bridge example snippets
use WPMedia\FleetBridge\Bridge;
use WPMedia\FleetBridge\Config;
use WPMedia\FleetBridge\Contract\TrustStore;
use WPMedia\FleetBridge\Exception\NotAuthorised;
use WPMedia\FleetBridge\WordPress\HttpKeySets;
use WPMedia\FleetBridge\WordPress\SystemClock;
use WPMedia\FleetBridge\WordPress\WpdbNonceStore;
$bridge = new Bridge(
$yourTrustStore, // you implement this
new HttpKeySets(),
new WpdbNonceStore(),
new Config( wp_parse_url( home_url(), PHP_URL_HOST ) ),
new SystemClock()
);
try {
$bridge->verifyCommand( $request->get_header( 'authorization' ), $request->get_body() );
$bridge->verifyGrant( $request->get_header( 'x-your-consent-header' ), 'settings:write' );
} catch ( NotAuthorised $refused ) {
// The reason is for your log. The caller gets Bridge::REFUSED and nothing
// else — see "One fixed refusal" below.
error_log( '[fleet] ' . $refused->getMessage() );
return new WP_Error( 'not_authorised', Bridge::REFUSED, [ 'status' => 401 ] );
}
final class MyTrustStore implements TrustStore {
public function issuer( string $role ): string {
// From wherever your plugin already talks to its vendor.
return $role === self::COMMAND ? $this->fleetIssuer() : $this->vendorIssuer();
}
public function keySetUrl( string $role ): string { /* … */ }
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.