BlockIo / block_io-php

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

Fatal error: Uncaught exception 'Exception' with message 'Failed: '... #5

Closed zerogods closed 9 years ago

zerogods commented 9 years ago

Maybe I'm doing something wrong?? Here's my code..

require_once '../libs/block_io.php'; //Block.io API
$version = 2; // API version
$pin = getenv('BLOCKIOPIN'); //Block_io main pin 
// echo $pin; // OK
$apiKey = getenv('dogetestnet'); //DOGE testnet
// echo $apiKey; // OK
$block_io = new BlockIo($apiKey, $pin, $version);
$Address = $block_io->get_my_addresses();  //this is line 34 at blockio_test.php

RETURNS

Notice: Trying to get property of non-object in ../repo/libs/block_io.php on line 107 Notice: Trying to get property of non-object in ../repo/libs/block_io.php on line 107 Notice: Trying to get property of non-object in ../repo/libs/block_io.php on line 107 Fatal error: Uncaught exception 'Exception' with message 'Failed: ' in ../repo/libs/block_io.php:107 Stack trace: # 0 ../repo/libs/block_io.php(60): BlockIo->_request('get_my_addresse...', Array) # 1 ../repo/php/blockio_test.php(34): BlockIo->__call('get_my_addresse...', Array) # 2 ../repo/php/blockio_test.php(34): BlockIo->get_my_addresses() # 3 {main} thrown in ../repo/libs/block_io.php on line 107

doersf commented 9 years ago

Hey, are you still seeing this?

The code seems fine. Could you provide the file you're using? Just the bits that lead to the error are fine.

We don't see an issue on our side.

zerogods commented 9 years ago

Still getting same error.. I cloned this repo and copied block_io.php file to /libs. [PHP 5.4.16, GMP 4.3.1, Mcrypt 2.5.8, cURL 7.19.7] This is my /blockio_test.php

ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);

require_once  '../libs/block_io.php'; //Block.io API
$version = 2; // API version
$pin ="<BlockIO PIN>"; //Block_io main pin 
$apiKey = "<DOGE testnet API KEY>"; //DOGE testnet
$block_io = new BlockIo($apiKey, $pin, $version);
$Address = $block_io->get_my_addresses();  //this line is throwing error
//print_r($Address);
doersf commented 9 years ago

Hi,

We're unable to reproduce this error with the given script aswell. I've filled the script out with a dummy PIN and API Key so you know the format. If you still get this error, we'll investigate further with the exact versions of extensions in use.

Script used:

<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);

require_once  '/home/user/php-libs/lib/block_io.php'; //Block.io API
$version = 2; // API version
$pin ="abraCadabra1"; //Block_io main pin 
$apiKey = "364f-754c-f129-99cd"; //DOGE testnet
$block_io = new BlockIo($apiKey, $pin, $version);
$Address = $block_io->get_my_addresses();  //this line is throwing error
print_r($Address);
?>

Response:

$ php test.php
stdClass Object
(
    [status] => success
    [data] => stdClass Object
        (
            [network] => DOGETEST
            [addresses] => Array
                (
                    [0] => stdClass Object
                        (
                            [user_id] => 0
                            [address] => 2N1GoeAj471UJvu8RfqL3jZ88TF8iTX22hG
                            [label] => default
                            [available_balance] => 100000.00000000
                            [pending_received_balance] => 0.00000000
                        )

                )

        )

)
zerogods commented 9 years ago

Namaste I'm still getting same error on localhost [WAMP] & openshift.

blockio

doersf commented 9 years ago

Hi, does your API key on the API Docs on the site? If yes, this seems to be a json_decode error. However, we're yet to verify this.

Simplest way to see the call works on Block.io: browse to https://block.io/api/v2/get_my_addresses/?api_key=YOURAPIKEY

Let us know.

zerogods commented 9 years ago

I've created another lib using cURL API for basic send/receive functions. Still need this lib for dtrust.

My testnet with cURL API is good and ready ~> https://test.NepalBit.co.in

zerogods commented 9 years ago

Oopss!! I forgot to restart WAMP after updating php.ini with path to cacert.pem. This lib was throwing same error in WAMP but now it's working fine. :)

Maybe this problem is part of openshift & recent bugs in SSL. So I tried few workarounds in openshift but failed.. Finally I removed [line 90] in block_io.php // curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'TLSv1'); // enforce use of TLSv1 and it's working fine.

Tried catching curl error and found

Error: 59: Unknown cipher in list: TLSv1

Is it ok to remove that line and add curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); ??

doersf commented 9 years ago

It's alright to remove it as long as it works. Block.io's servers will only support TLS, and not SSL. As long as your cURL extension default to TLSv1, you'll be fine.

Glad you got this sorted out, and thanks for letting us know :)

If there isn't much else to it, I'll close this issue. We're not going to remove that line by default just yet -- some folks will use outdated cURL that will cause problems because it defaults to SSLv3.

zerogods commented 9 years ago

Thanks for this cool API and your fast replies.. :)

Peace!!