1. Go to this page and download the library: Download viz-blockchain/viz-php-lib 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/ */
viz-blockchain / viz-php-lib example snippets
vate_key=new VIZ\Key('b9f3c242e5872ac828cf2ef411f4c7b2a710bd9643544d735cc115ee939b3aae');
print 'Private key from hex: '.$private_key->hex.PHP_EOL;
print 'Private key WIF: '.$private_key->encode().PHP_EOL;
$data='Hello VIZ.World! '.date('d.m.Y H:i:s');
print 'Data for signing: '.$data.PHP_EOL;
$signature=$private_key->sign($data);
if(false===$signature){
print 'Canonical signature was not found, please try again.';
}
else{
print 'Signature: '.$signature.PHP_EOL;
$public_key=$private_key->get_public_key();
$recovered_public_key=$public_key->recover_public_key($data,$signature);
print 'Recovered public key from signature: '.$public_key->encode().PHP_EOL;
if($public_key){
print 'Public key from private: '.$public_key->encode().PHP_EOL;
print 'Verify signature status for same data: '.var_export($public_key->verify($data,$signature),true).PHP_EOL;
print 'Verify signature status for other data: '.var_export($public_key->verify('Bye VIZ.World!',$signature),true).PHP_EOL;
}
}
unt='test';
$private_key='5K...';//regular
$tx=new VIZ\Transaction('https://node.viz.plus/',$private_key);
$tx_data=$tx->custom([],[$account],'test','{"msg":"testing viz-php-lib custom operation"}');
var_dump($tx_data);
$tx->api->return_only_result=false;
//second attribute is synchronous, if setted then return block num where transaction was witnessed
$tx_status=$tx->execute($tx_data['json'],true);
var_dump($tx_status);
unt='test';
$private_key='5K...';//regular
$tx=new VIZ\Transaction('https://api.viz.world/',$private_key);
$fee='0.000 VIZ';
$delegation='10.000000 SHARES';
//you can set any authority as simple string with encoded public key
$master='VIZ7RXhpaw8SbedSp84EqMGGzeBZgAPLEn7D6kQhJu8bMMvUKtuxk';//5JRd4Toy8cmDr15qEtZieqAgbg3qQMU6n8cPC1Las2hBah46tr1
$active='VIZ7H8S8rHkKQkX8bSUpDtBAwy8tTphq2NH7ZRv1dcCvk1Cjz38nK';//5JvgdGsA5M8rZ9oY2p7qcKkexG1kWqN2jQcQ6afEPCqQXrKTsbS
//or make full authority struct (if you need more flexibility)
$regular=[
//'weight_threshold'=>1,//can be empty if weight_threshold=1
'account_auths'=>[
['on1x',1]
],
'key_auths'=>[
['VIZ5bGNeJPjoDdZTEK3LSMUfP21gcBH34AdMPHpvQymuYMk2YMbsB',1],//5HuHKQhiiAAAp7zMCgRpCCyv8hramEmzAzDUagrhMkTWDhyVtK6
['VIZ5jWA94PYBanGSPhTyWrwvT8RAJcnB7onXGvK5DnzbxB6874yap',1]//5KESchwZvs67C4Xz5SQQ1ea4N9rZR67NEvi6yemWpSYoKo9eTrM
]
];
//you need manually check public keys sorting in key_auths or node will refuse the transaction
$memo_key='VIZ1111111111111111111111111111111114T1Anm';//can be empty key
$json_metadata='';
$referrer='';
$new_account_name='test-lib';
$tx_data=$tx->account_create($fee,$delegation,$account,$new_account_name,$master,$actove,$regular,$memo_key,$json_metadata,$referrer);
var_dump($tx_data);
$tx->api->return_only_result=false;
$tx_status=$tx->execute($tx_data['json']);
var_dump($tx_status);
unt='test';
$private_key='5K...';//regular
//$endpoint,$key,$account,$text,$reply=false,$share=false,$beneficiaries=false,$loop=false
$status=VIZ\Utils::voice_text('https://api.viz.world/',$private_key,$account,'Test from viz-php-lib');
var_dump($status);
unt='test';
$private_key='5K...';//regular
$markdown='Well, Voice protocol markdown have **bold**, __italic__, ~~stroke~~ and `code`
## Headers 2
### And 3
Also we got:
> Quotes and
>> Second style for citation
Support lists:
* Unordered
* as ordinary
* items
And ordered, ofc:
*n Yes
*n it is!
After all, simple images:

Paragraph
with
multiline
...and #en #example tags support :)';
//$endpoint,$key,$account,$title,$markdown,$description,$image,$reply=false,$share=false,$beneficiaries=false,$loop=false,$synchronous=false
$status=VIZ\Utils::voice_publication('https://api.viz.world/',$private_key,$account,'Test publication from viz-php-lib',$markdown);
var_dump($status);
unt='test';
$private_key='5K...';
$text='Test text and event from viz-php-lib';
//create Voice object with text type (last attribute is synchronous that returns block num where is transaction was witnessed)
$object_block_num=VIZ\Utils::voice_text('https://api.viz.world/',$private_key,$account,$text,false,false,false,false,true);
print 'Object: viz://@'.$account.'/'.$object_block_num.'/';
//hide event
$event_block_num=VIZ\Utils::voice_event('https://api.viz.world/',$private_key,$account,'h',false,$object_block_num,false,false,true);
print 'Hide event for this object: viz://@'.$account.'/'.$object_block_num.'/?event='.$event_block_num;
unt='test';
$private_key='5K...';
$max_size_limit=65280;
$part_size=1024*10;//10Kb
$long_text='...';//long text more that $max_size_limit bytes
//create Voice object with text type (last attribute is synchronous that returns block num where is transaction was witnessed)
$tx_prepare=VIZ\Utils::voice_text('https://api.viz.world/',$private_key,$account,$long_text,false/*reply*/,false/*share*/,false/*beneficiaries*/,false/*loop*/,true/*synchronous*/,true/*raw tx*/);
$tx_length=strlen($tx_prepare['data'])/2;
if($tx_length<$max_size_limit){
$object_block_num=VIZ\Utils::voice_text('https://api.viz.world/',$private_key,$account,$long_text,false/*reply*/,false/*share*/,false/*beneficiaries*/,false/*loop*/,true/*synchronous*/,false/*raw tx*/);
if($object_block_num){
print 'Object: viz://@'.$account.'/'.$object_block_num.'/';
}
else{
print 'Object error';
}
}
else{
$tx_diff=$tx_length-$max_size_limit;
$parts_count=ceil($tx_diff / $part_size);
$markdown_length=mb_strlen($long_text);
$main_part_length=$markdown_length-($parts_count*$part_size);
if($main_part_length<0){
$main_part_length=$part_size;
}
$main_part=mb_substr($long_text,0,$main_part_length);
$secondary_part=mb_substr($long_text,$main_part_length);
$object_block_num=VIZ\Utils::voice_text('https://api.viz.world/',$private_key,$account,$main_part,false/*reply*/,false/*share*/,false/*beneficiaries*/,false/*loop*/,true/*synchronous*/,false/*raw tx*/);
if($object_block_num){
print 'Main object: viz://@'.$account.'/'.$object_block_num.'/'.PHP_EOL;
//add event
$event_block_num=VIZ\Utils::voice_event('https://api.viz.world/',$private_key,$account,'a',false,$object_block_num,false/*data_type*/,['t'=>$secondary_part]/*data*/,true/*synchronous*/,false/*raw tx*/);
if($event_block_num){
print 'Add event for this object: viz://@'.$account.'/'.$object_block_num.'/?event='.$event_block_num;
}
else{
print 'Event error';
}
}
else{
print 'Object error';
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.