requires_token( false ); } /** * Allows you to do things before any output has been sent to the browser. * This means you can redirect to a remote site, another page etc if need be. */ function request_token() { // Nothing to do in this example } /** * You can define how a token presents itself to the user here. For example for Twitter, * we might show "@" . $screen_name. * * @param Keyring_Access_Token $token * @return String for use in UIs etc that helps identify this specific token */ function get_display( Keyring_Access_Token $token ) { return $token->token; } /** * See __construct() for details on how this is hooked in to handle the UI for * during the request process. */ function request_ui() { Keyring::admin_page_header(); // Generic header which can be used (includes h2 header) echo '

This is just an example of how you could display some sort of custom UI if you needed to.

'; echo '

Clicking the button below will generate a random token and store it as an example.

'; echo '

'; echo '' . __( 'Continue', 'keyring' ) . ''; echo 'Abort'; echo '

'; Keyring::admin_page_footer(); } /** * Allows you to do things before any output has been sent to the browser. * This means you can redirect to a remote site, another page etc if need be. */ function verify_token() { // Generate a fake token and store it for this example $token = sha1( time() . mt_rand( 0, 1000 ) . time() ); $meta = array( 'time' => time(), 'user' => get_current_user() ); $this->store_token( $token, $meta ); } /** * This method will be used to make requests against this service. This is where * you should handle injecting tokens/headers/etc required for authentication. * * @param string $url * @param array $params additional parameters/headers for the request. Passed to WP_Http * @return Response body as a string, or a Keyring_Error with the full WP_Http response object as the "message" */ function request( $url, array $params = array() ) { // empty } /** * See __construct() for details on how this is hooked in to handle the UI for * during the verify process. */ function verify_ui() { Keyring::admin_page_header(); echo '

As an example, we just randomly generated a token and saved it in the token store. When you go back to your Connections listing, you should see it listed there under "Example Service".

'; echo '

' . __( 'Done', 'keyring' ) . ''; Keyring::admin_page_footer(); } } // Always hook into keyring_load_services and use your init method to initiate a Service properly (singleton) add_action( 'keyring_load_services', array( 'Keyring_Service_Example', 'init' ) );