Author

Topic: MTGOX api, send simple not working. [solved ] (Read 891 times)

legendary
Activity: 1946
Merit: 1035
Thank you so much for your very generous donation. It is very much appreciated, I take it as an incentive to further help you and others with coding issues involving the Gox API and PHP (had to go through this myself, with my own implementation of the JSON RPC API though).

Cheers,

Matt
newbie
Activity: 46
Merit: 0
Thank you very much Matt,

That quick hack was indeed correct


legendary
Activity: 1946
Merit: 1035
corrected order, still getting same error :/


noticed the end of the error changed when I switched them

backwards
 13 [function] => withdraw_coins [class] => MtGox_Private_Api [type] => -> [args] => Array (
  • => 1 [1] => 14XnxAbrNZkkXRX76MS2S5JnJ1hUbgCs1Y ) ) ) [previous:Exception:private] => )

correct
13 [function] => withdraw_coins [class] => MtGox_Private_Api [type] => -> [args] => Array (
  • => 14XnxAbrNZkkXRX76MS2S5JnJ1hUbgCs1Y [1] => 1 ) ) ) [previous:Exception:private] => )


but other then that the error is the same. (sent you a little bit for taking the time to look)  Smiley

Thanks.

I looked further into the API, I don't understand how it could work. Try changing withdraw_coins() in mtgox_private_api.php this way:

Code:
    // Send bitcoins from your account to a bitcoin address. 
    
public function withdraw_coins($address$amount_int$fee_int=null$no_instant=null$green=null)
    {
        
$params = array(
            
'address' => $address,
            
'amount_int' => $amount_int
        
);
        return 
$this->send_request(self::uri_withdraw_coins$params);
    }
?>


It's a quick hack out of my imagination. Tell me if it works or not, if I have time I will look further into it.
newbie
Activity: 46
Merit: 0
corrected order, still getting same error :/


noticed the end of the error changed when I switched them

backwards
 13 [function] => withdraw_coins [class] => MtGox_Private_Api [type] => -> [args] => Array (
  • => 1 [1] => 14XnxAbrNZkkXRX76MS2S5JnJ1hUbgCs1Y ) ) ) [previous:Exception:private] => )

correct
13 [function] => withdraw_coins [class] => MtGox_Private_Api [type] => -> [args] => Array (
  • => 14XnxAbrNZkkXRX76MS2S5JnJ1hUbgCs1Y [1] => 1 ) ) ) [previous:Exception:private] => )


but other then that the error is the same. (sent you a little bit for taking the time to look)  Smiley
legendary
Activity: 1946
Merit: 1035
According to the source on github, you are calling withdraw_coins() with arguments in the wrong orders.

Here's code from the API:

Code:
    // Send bitcoins from your account to a bitcoin address. 
    
public function withdraw_coins($address$amount_int$fee_int=null$no_instant=null$green=null)
    {
        return 
$this->send_request(self::uri_withdraw_coins);
    }
?>


You should try swapping $address and $amount_int:

Code:
    try {
        
$send_simple $private->withdraw_coins($address$amount_int);
        
print_r($send_simple);
    } catch(
Exception $e) {
        
print_r($e);
    }
?>


If that solves your problem, tips appreciated ;-)

BTC: 13otqU1gvatwws9euEZczTXiBWhvcHUrGq

Cheers,

Matt
newbie
Activity: 46
Merit: 0
I do not have any 2 factor enabled;

and the key does have withdraw enabled. 
BCB
vip
Activity: 1078
Merit: 1002
BCJ
do you have otp enabled
newbie
Activity: 46
Merit: 0
.1btc

my script
Code:
include 'mtgox_api_base.php';
include 
'mtgox_private_api.php';

$private = new MtGox_Private_Api();
$private->set_currency('USD'); // CHANGE TO USD IF YOU NEED USD!!
$private->set_authentication("SSSSSSSSSSSSSSSS""SSSSSSSSSSSSSSSSSSSSSSS");

$address '14XnxAbrNZkkXRX76MS2S5JnJ1hUbgCs1Y';
$amount_int 10000;

try{
    
$send_simple $private->withdraw_coins($amount_int$address);
    
print_r($send_simple);
}catch(
Exception $e) {
    
print_r($e);
}
?>


is returning the error

Quote
Exception Object ( [message:protected] => Parameter amount_int or amount is required [string:Exception:private] => [code:protected] => 0 [file:protected] => /var/www/admin/atm/mtgox_api_base.php [line:protected] => 79 [trace:Exception:private] => Array (
  • => Array ( [file] => /var/www/admin/atm/mtgox_api_base.php [line] => 70 [function] => process_api_response [class] => MtGox_Api_Base [type] => -> [args] => Array (
  • => Array ( [result] => error [error] => Parameter amount_int or amount is required [token] => unknown_error ) ) ) [1] => Array ( [file] => /var/www/admin/atm/mtgox_private_api.php [line] => 46 [function] => send_request [class] => MtGox_Api_Base [type] => -> [args] => Array (
  • => 1/generic/bitcoin/send_simple ) ) [2] => Array ( [file] => /var/www/admin/atm/history.php [line] => 13 [function] => withdraw_coins [class] => MtGox_Private_Api [type] => -> [args] => Array (
  • => 10000 [1] => 14XnxAbrNZkkXRX76MS2S5JnJ1hUbgCs1Y ) ) ) [previous:Exception:private] => )
BCB
vip
Activity: 1078
Merit: 1002
BCJ
how much is the bounty
newbie
Activity: 46
Merit: 0
*bumb added bounty
newbie
Activity: 46
Merit: 0
if I use https://data.mtgox.com/api/

I get the following error;

Exception Object ( [message:protected] => Could not get reply: Unknown SSL protocol error in connection to data.mtgox.com:443 [string:Exception:private] => [code:protected] => 0 [file:protected] => /var/www/admin/atm/mtgox_api_base.php [line:protected] => 111 [trace:Exception:private] => Array (
  • => Array ( [file] => /var/www/admin/atm/mtgox_api_base.php [line] => 69 [function] => post_api_request [class] => MtGox_Api_Base [type] => -> [args] => Array (
  • => 1/generic/bitcoin/send_simple [1] => Array ( ) ) ) [1] => Array ( [file] => /var/www/admin/atm/mtgox_private_api.php [line] => 46 [function] => send_request [class] => MtGox_Api_Base [type] => -> [args] => Array (
  • => 1/generic/bitcoin/send_simple ) ) [2] => Array ( [file] => /var/www/admin/atm/history.php [line] => 13 [function] => withdraw_coins [class] => MtGox_Private_Api [type] => -> [args] => Array (
  • => 14XnxAbrNZkkXRX76MS2S5JnJ1hUbgCs1Y [1] => 1 ) ) ) [previous:Exception:private] => )

 
newbie
Activity: 46
Merit: 0
used your script and getting the following error as well. ( i do have btc in the account.)

Exception Object ( [message:protected] => Parameter amount_int or amount is required [string:Exception:private] => [code:protected] => 0 [file:protected] => /var/www/admin/atm/mtgox_api_base.php [line:protected] => 79 [trace:Exception:private] => Array (
  • => Array ( [file] => /var/www/admin/atm/mtgox_api_base.php [line] => 70 [function] => process_api_response [class] => MtGox_Api_Base [type] => -> [args] => Array (
  • => Array ( [result] => error [error] => Parameter amount_int or amount is required [token] => unknown_error ) ) ) [1] => Array ( [file] => /var/www/admin/atm/mtgox_private_api.php [line] => 46 [function] => send_request [class] => MtGox_Api_Base [type] => -> [args] => Array (
  • => 1/generic/bitcoin/send_simple ) ) [2] => Array ( [file] => /var/www/admin/atm/history.php [line] => 13 [function] => withdraw_coins [class] => MtGox_Private_Api [type] => -> [args] => Array (
  • => 14XnxAbrNZkkXRX76MS2S5JnJ1hUbgCs1Y [1] => 1 ) ) ) [previous:Exception:private] => )


post an address and I can send some btc for testing.
newbie
Activity: 9
Merit: 0
I wrote some test code and got the following exception:

"Parameter amount_int or amount is required" - Which is the default exception if something is wrong. Currently i have no BTC in my account, so i suspect that's why i get this error. Can you please try with the following code?

START CODE
include 'mtgox_api_base.php';
include 'mtgox_private_api.php';

$private = new MtGox_Private_Api();
$private->set_currency('EUR'); // CHANGE TO USD IF YOU NEED USD!!
$private->set_authentication("KEY", "SECRET");
try{
    $send_simple = $private->withdraw_coins("BTC ADDRESS", "AMOUNT (eg. 0)");
    print_r($send_simple);
}catch(Exception $e) {
    print_r($e);
}

?>
END CODE

Please let me know if this works.

-Navles
newbie
Activity: 9
Merit: 0
M... weird.

I'm setting up a test environment as we speak.

I will get back to you in a second.

-Navles
newbie
Activity: 46
Merit: 0
actually adding data. breaks the get account info as well

const api_url = 'https://data.mtgox.com/api/'; FAILD

const api_url = 'https://mtgox.com/api/'; returns only on the get account into, not send simple


might this have something to do with the https?
newbie
Activity: 46
Merit: 0
I just entered the data. and still returned a blank page.

tinkering
newbie
Activity: 9
Merit: 0
By the way,

I noticed MT. GOX changed their API URL from "https://mtgox.com/api/" to "https://data.mtgox.com/api/".

Try changing the API base url to "https://data.mtgox.com/api/" in mtgox_api_base.php  line 10.

Let me know if that works.

EDIT:

Also dont forget to enable 'withdraw' rights in the security center.

https://f.cloud.github.com/assets/738972/49695/9967f3ca-5976-11e2-903d-66674970cc0b.png

-Navles
newbie
Activity: 9
Merit: 0
Hello,

Do you have OTP enabled for your account?

-Navles
newbie
Activity: 46
Merit: 0
I found a php script for mtgox's api that is working for me.

https://github.com/daftspunk/php-mtgox-v1


here is my script, some of the functions work, some dont...

Trying to get a send simple to a bitcoin address.


http://pastebin.com/wihZqAcW
Jump to: