PHP code example of elqora / interactions

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

    

elqora / interactions example snippets


'image' => [
    'type' => 'url', // or 'data_uri'
    'src' => 'https://example.com/qr.png', // or 'data:image/png;base64,...'
]

use Elqora\Interactions\Interactions\Instructions;
use Elqora\Interactions\Enums\Presentation;

// Construct an instructions interaction
$interaction = new Instructions(
    content: "# Complete Verification\n\nPlease submit your ID.",
    title: "Verification",
    metadata: ["user_id" => 42],
    presentation: Presentation::Dialog
);

// Serialize to canonical flat wire format
$payload = $interaction->toArray();
/*
[
    'type' => 'instructions',
    'content' => "# Complete Verification\n\nPlease submit your ID.",
    'title' => 'Verification',
    'metadata' => ['user_id' => 42],
    'presentation' => 'dialog',
]
*/

use Elqora\Interactions\Serialization\InteractionFactory;

$payload = [
    'type' => 'redirect',
    'url' => 'https://elqora.com/dashboard',
    'replace' => true
];

$interaction = InteractionFactory::fromArray($payload);

echo $interaction->url; // "https://elqora.com/dashboard"