BlockIo / block_io-php

PHP library for Block.io
MIT License
56 stars 139 forks source link

Summarize, sign and submit transaction is not working #52

Closed HopekellDev closed 2 years ago

HopekellDev commented 2 years ago

I tried to follow the example but when I try to sign a transaction or summarize, I will get the following error: Fatal error: Uncaught Error: Object of class stdClass could not be converted to string in /home/dolphine/public_html/vendor/block_io-php/block_io-php/lib/block_io.php:86 Stack trace: #0 /home/dolphine/public_html/vendor/block_io-php/block_io-php/lib/block_io.php(65): BlockIo->_request('summarize_prepa...', Object(stdClass)) #1 /home/dolphine/public_html/json_test.php(16): BlockIo->__call('summarize_prepa...', Object(stdClass)) #2 {main} thrown in /home/dolphine/public_html/vendor/block_io-php/block_io-php/lib/block_io.php on line 86

Below is what My Code look like: `ini_set('display_errors', 1); include "./vendor/autoload.php"; $apiKey = "dogeTestApixxx"; $version = 2; // API version $pin = "xxxxxxxx"; $block_io = new BlockIo($apiKey, $pin, $version);

// $data = $block_io->prepare_transaction(array('amounts' => '100', 'from_addresses' => '2N6p8xNx47n8DqKCqbvMqXPbTttPT26T9BX', 'to_addresses' => '2N5p5Z7E5rXSKXdpAHJdd3jn1HFWkWjd1yJ')); $address = "2N5p5Z7E5rXSKXdpAHJdd3jn1HFWkWjd1yJ"; $sendAmount = 100; $prepare_transaction_response = $block_io->prepare_transaction(array('to_address' => $address, 'amount' => $sendAmount));

// the summary of the prepared transaction // for in-depth data, inspect the $prepare_transaction_response directly print json_encode($block_io->summarize_prepared_transaction($prepare_transaction_response)) . PHP_EOL;`

doersf commented 2 years ago

You haven't installed the library v2.0+. See https://github.com/BlockIo/block_io-php/issues/50#issuecomment-1228198208.