Bitcoin Forum
November 01, 2024, 10:43:35 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: MTGOX api, send simple not working. [solved ]  (Read 893 times)
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
May 22, 2013, 07:27:48 PM
Last edit: May 23, 2013, 06:39:46 PM by BitvoinVender
 #1

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
Navles
Newbie
*
Offline Offline

Activity: 9
Merit: 0


View Profile
May 22, 2013, 07:40:08 PM
 #2

Hello,

Do you have OTP enabled for your account?

-Navles
Navles
Newbie
*
Offline Offline

Activity: 9
Merit: 0


View Profile
May 22, 2013, 07:42:49 PM
 #3

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
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
May 22, 2013, 08:03:22 PM
 #4

I just entered the data. and still returned a blank page.

tinkering
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
May 22, 2013, 08:07:50 PM
 #5

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?
Navles
Newbie
*
Offline Offline

Activity: 9
Merit: 0


View Profile
May 22, 2013, 08:43:52 PM
 #6

M... weird.

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

I will get back to you in a second.

-Navles
Navles
Newbie
*
Offline Offline

Activity: 9
Merit: 0


View Profile
May 22, 2013, 09:11:54 PM
 #7

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
<?php
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
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
May 22, 2013, 10:53:41 PM
 #8

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.
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
May 22, 2013, 11:04:19 PM
 #9

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] => )

 
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
May 23, 2013, 02:29:44 AM
 #10

*bumb added bounty
BCB
CTG
VIP
Legendary
*
Offline Offline

Activity: 1078
Merit: 1002


BCJ


View Profile
May 23, 2013, 02:31:50 AM
 #11

how much is the bounty
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
May 23, 2013, 02:36:20 AM
 #12

.1btc

my script
Code:
<?php
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
CTG
VIP
Legendary
*
Offline Offline

Activity: 1078
Merit: 1002


BCJ


View Profile
May 23, 2013, 02:45:48 AM
 #13

do you have otp enabled
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
May 23, 2013, 03:54:36 AM
 #14

I do not have any 2 factor enabled;

and the key does have withdraw enabled. 
matt4054
Legendary
*
Offline Offline

Activity: 1946
Merit: 1035



View Profile
May 23, 2013, 04:03:30 AM
 #15

According to the source on github, you are calling withdraw_coins() with arguments in the wrong orders.

Here's code from the API:

Code:
<?php
    
// 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:
<?php
    
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
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
May 23, 2013, 05:45:40 AM
 #16

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
matt4054
Legendary
*
Offline Offline

Activity: 1946
Merit: 1035



View Profile
May 23, 2013, 06:11:01 AM
 #17

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:
<?php
    
// 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.
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
May 23, 2013, 05:26:18 PM
Last edit: May 23, 2013, 06:37:28 PM by BitvoinVender
 #18

Thank you very much Matt,

That quick hack was indeed correct


matt4054
Legendary
*
Offline Offline

Activity: 1946
Merit: 1035



View Profile
May 23, 2013, 07:00:13 PM
 #19

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
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!