Bitcoin Forum

Other => Beginners & Help => Topic started by: de_bert on June 18, 2011, 12:27:48 PM



Title: Mt. Gox API problems
Post by: de_bert on June 18, 2011, 12:27:48 PM
Hi,

Unfortunately, I need to post this here as I'm considered a newbie.

I have a problem with the Mt. Gox trading API, namely with the buy and sell scripts:
Code:
https://www.mtgox.com/code/sellBTC.php?name=USERNAME&pass=PASS&amount=3&price=30
will give me "{"error": "Not logged in. <a href='/users/login'>Log in</a>"}".
A call to
Code:
https://mtgox.com/code/getOrders.php?name=USERNAME&pass=PASS
works, however.

It does not work in a browser, but it also does not work in JS:
Code:
$.ajax({
            type: 'POST',
            url: 'https://mtgox.com/code/sellBTC.php?name=USERNAME&pass=PASS&amount=' + numAmount + '&price=' + numPrice,
            dataType: 'json',
            data: {},
            success: this.onSellSuccess.bind(this, funCallback),
            error: this.onSellFailure.bind(this, funCallback)
        }); 
will not work either, yielding the same error.

As I found few people having the same problem and no answers, I'm wondering whether I'm doing something wrong....
Also Mt. Gox support did not answer my request for help.


Title: Re: Mt. Gox API problems
Post by: you2 on June 18, 2011, 12:34:12 PM
Off Topic:
Are you sure you want to send the username and password not encrypted through an ajax request?
Anybody could read the source code in the browser.


Title: Re: Mt. Gox API problems
Post by: de_bert on June 18, 2011, 12:38:03 PM
Off Topic:
Are you sure you want to send the username and password not encrypted through an ajax request?
Anybody could read the source code in the browser.

It's just an example, it will of course support everyone's own login. It's still unencrypted, yes, but that's Mt. Gox's fault.
Also I would not give out a buy/sell interface to my account :-)


Title: Re: Mt. Gox API problems
Post by: Ian Maxwell on June 19, 2011, 07:02:28 AM
I'm having the same problem, except that I get
Code:
{"error":"Not logged in. <a href='\/users\/login'>Log in<\/a>"}
which is a bit less reasonable than what you're getting.


Title: Re: Mt. Gox API problems
Post by: de_bert on June 19, 2011, 08:31:39 AM
I finally found the solution, described here:
http://forum.bitcoin.org/index.php?topic=19077.msg242110#msg242110