Wordpress Interface with Hive Keychain.
blog·@diggndeeper.com·
0.000 HBDWordpress Interface with Hive Keychain.
<center>https://diggndeeper.com/wp-content/uploads/2020/03/cropped-logo-2k.png</center> <br/><figure class="wp-block-embed is-type-wp-embed is-provider-diggndeeper wp-block-embed-diggndeeper"><div class="wp-block-embed__wrapper"> https://diggndeeper.com/wp-dapp/ </div></figure> <p><a rel="noreferrer noopener" class="keychainify-checked" href="https://hive-keychain.com/" target="_blank">Hive Keychain</a> integration requires the Hive Keychain API. </p> <ol><li>Register with Hive Keychain API. Provide information such as your application name, description, and callback URL.</li> <li>Hive Keychain API requests permission from users to access their Hive accounts. Use the <code>hive_keychain_requestPermission</code> function to prompt the user to grant permission.</li> <li>After the user has granted permission, you can use the <code>hive_keychain_broadcast</code> function to broadcast transactions to the Hive blockchain. You will need to pass in the transaction object and the user's account name and permission.</li> <li>You can also use the <code>hive_keychain_signBuffer</code> function to sign messages with the user's private key.</li> </ol> <p><a rel="noreferrer noopener" class="keychainify-checked" href="https://cloud.diggndeeper.com/index.php/s/Wcd2PPorBTBPNQt" target="_blank">wp-dapp.php</a> on Nextcloud</p> <pre class="wp-block-code"><code><?php /** * Plugin Name: wp-dapp * Description: Hive Keychain API * Version: .0.0 */ // Add the Hive Keychain API script to the header function add_hive_keychain_api_script() { wp_enqueue_script( 'hive-keychain-api', 'https://cdn.jsdelivr.net/npm/hive-keychain-api@1.2.0/index.js', array(), null, true ); } add_action( 'wp_enqueue_scripts', 'add_hive_keychain_api_script' ); // Add a shortcode that displays a form to post a message to Hive function hive_post_form_shortcode() { ob_start(); ?> <form id="hive-post-form"> <input type="text" name="message" placeholder="Enter your message"> <button type="submit">Post to Hive</button> </form> <div id="hive-post-result"></div> <script> // Handle form submission document.getElementById( 'hive-post-form' ).addEventListener( 'submit', function( event ) { event.preventDefault(); // Get the user's Hive account name and permission from Hive Keychain hive_keychain.requestAccount( function( account ) { if ( ! account ) { alert( 'Please install and authorize Hive Keychain to use this feature.' ); return; } // Get the message from the form input var message = document.querySelector( 'input[name="message"]' ).value; // Construct the Hive transaction object var tx = { 'operations': [[ 'comment', { 'parent_author': '', 'parent_permlink': 'test', 'author': account.name, 'permlink': 'my-post', 'title': '', 'body': message, 'json_metadata': '{}' } ]] }; // Broadcast the transaction to Hive hive_keychain.broadcast( account.name, 'posting', tx, function( response ) { if ( response.success ) { document.getElementById( 'hive-post-result' ).innerHTML = 'Your message was posted to Hive!'; } else { document.getElementById( 'hive-post-result' ).innerHTML = 'There was an error posting your message to Hive.'; } }); }); }); </script> <?php return ob_get_clean(); } add_shortcode( 'hive_post_form', 'hive_post_form_shortcode' );</code></pre> <p>This code does the following:</p> <ul><li>Adds the Hive Keychain API script to the header of the plugin's pages.</li> <li>Defines a shortcode <code>hive_post_form</code> that displays a form to post a message to Hive.</li> <li>Uses the <code>hive_keychain.requestAccount</code> function to get the user's Hive account name and permission.</li> <li>Constructs a Hive transaction object that posts the message to the <code>test</code> tag on the Hive blockchain.</li> <li>Uses the <code>hive_keychain.broadcast</code> function to broadcast the transaction to Hive.</li> </ul> <ol start="3"><li>Save the <code>wp-dapp.php</code> file and activate the plugin in</li> </ol> <p>We can store the files on our <a rel="noreferrer noopener" class="keychainify-checked" href="https://cloud.diggndeeper.com" target="_blank">Nextcloud Hub</a>. This hub needs work. It is cloud hosted and limited and I would really like to build a <a class="keychainify-checked" href="https://diggndeeper.com/node-master/" data-type="post" data-id="255">Node Master</a> connected to <a href="http://mesh" data-type="URL" data-id="mesh">Meshnets</a> to solve all our development problems. </p> <br /><center><hr/><em>Posted from my blog with <a href='https://wordpress.org/plugins/exxp/'>Exxp</a> : https://diggndeeper.com/wordpress-interface-with-hive-keychain/ </em><hr/></center>
👍 freebornsociety, steelbak, alexis555, steemonob, farrier.services, flyinghigher, liljespy, william-gregory, mcgi.cares, fatimajunio, angelowkhelow, anytime-soon, hiro-hive, give-cat-food, crisgojar, fatherfaith, collinz, eastmael, norat23, ubani, eldaniel0131, sucal, argeh, potpourry, sparker005, princess001, tildy, zenai, emmy3, angelic01, tbliz, charlotte01, eliseo.soriano, shalom0809, blackdovy, emmanuel222, joven777, drbenzz, kingly0, gone-hive, odsam2, citimillz, simplymeekarts, opopa, cyber-tech, ekc88, pana1, getron, banat, joseystarr, dejan.vuckovic, daniel-vs, viktoria-erina, vragolana, sarka-vs, gestex, suzana72, tina-vs, viki76, sportal, grad.best, ujka-vs, lov.plus, prudens, rebekica, ivanas, ivana-81, lazar01, bilbija, dorika-bee, jonela, elizahfhaye, vid.observer, tftproject, ericwilson, zawiel, acidyo, alphacore, gniksivart, xves, mister-meeseeks, ghaazi, leveluplifestyle, trasto, supreme-verdict, meltysquid, sweetest, steemychicken1, prolinuxua, borislavzlatanov, deepresearch, techguard, offgridlife, mar-marzu, cryptokungfu,