PHP code example of ezadr / lnurl-php

1. Go to this page and download the library: Download ezadr/lnurl-php 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/ */

    

ezadr / lnurl-php example snippets


$ composer 



za\lnurl;

// Encode a URL to LNURL
$lnurl = lnurl\encodeUrl('https://paywall.link?someIdentifier=292e29j29j19nd91m2mfmmurn843&tag=withdraw');
//LNURL1DP68GURN8GHJ7URP09MKZMRV9EKXJMNT8AEK7MT9F9JX2MN5D9NXJETJ85ERJVN9XGUK5V3EDGCNJMNY8YCK6VNDVEKK6ATJDCURGVEXW3SKW0THD96XSERJV9MS95LDUW

// Decode from LNURL
print_r( lnurl\decodeUrl($lnurl) );
/*
 * [
 *   'url' => 'https://paywall.link?someIdentifier=292e29j29j19nd91m2mfmmurn843&tag=withdraw',
 *   'tag' => 'withdraw'
 *   'someIdentifier' => '292e29j29j19nd91m2mfmmurn843'
 * ] 
 */
 
// LNURL Auth
if (lnurl\auth($request->k1, $request->signature, $request->wallet_public_key)) {
    // fetch or create user then authenticate
}