BlockIo / block_io-php

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

get_user_balance doesn't receive user_id, shows same balance as get_balance #3

Closed tim-peterson closed 10 years ago

tim-peterson commented 10 years ago

get_user_balance doesn't properly accept user_id as a param. It shows the same balance as the total account, i.e., get_balance.

doersf commented 10 years ago

Hey Tim, here's what I see:

$ curl https://block.io/api/v1/get_balance/?api_key=YOURDOGEAPIKEY { "status": "success", "data": { "network": "DOGE", "available_balance": "XYZAMOUNT.DECIMALS", "unconfirmed_sent_balance": "0.00000000", "unconfirmed_received_balance": "0.00000000" } }

$ curl https://block.io/api/v1/get_balance/?api_key=YOURDOGEAPIKEY\&user_id=0 { "status": "success", "data": { "network": "DOGE", "available_balance": "0.00000000", "unconfirmed_sent_balance": "0.00000000", "unconfirmed_received_balance": "0.00000000", "user_id": 0, "address": "DR......", "label": "default" } }

Seems to be working as intended. Do you have an example URL you can give us to replicate this?

tim-peterson commented 10 years ago

The issue is with the PHP library. The PHP methods are called get_balance and get_user_balance, but neither will recognize when I plug in a user_id.

For example, this gives the balance for the total account and not user 7:

$data['balance'] = $doge->get_balance(array("user_id" => 7));

doersf commented 10 years ago

Tim, I see how you're using it. It was originally intended to simply get the balance for the entire account, and get_user_balance was supposed to be for specifics.

I've changed the library to allow get_balance to accept/pass arguments. I've updated Composer, as well as version numbers on the API docs. New version: 0.2.1. Thanks :)

doersf commented 10 years ago

By the way, get_user_balance should accept user_id as is. Can you update this after you try with the new library?

Here's what I'm doing:

print $block_io->get_user_balance(array('user_id' => 38))->data->available_balance;

tim-peterson commented 10 years ago

Sorry for the delay. Just updated to 0.2.1 and now both get_balance and get_user_balance work with arguments, e.g.,

$blockio->get_user_balance(array("label" => "my_user_label"));

Thanks again!