Bitcoin Forum
May 12, 2024, 03:48:15 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Mt. Gox API problems  (Read 1461 times)
de_bert (OP)
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
June 18, 2011, 06:54:48 PM
 #1

Hi,

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.
1715485695
Hero Member
*
Offline Offline

Posts: 1715485695

View Profile Personal Message (Offline)

Ignore
1715485695
Reply with quote  #2

1715485695
Report to moderator
1715485695
Hero Member
*
Offline Offline

Posts: 1715485695

View Profile Personal Message (Offline)

Ignore
1715485695
Reply with quote  #2

1715485695
Report to moderator
Make sure you back up your wallet regularly! Unlike a bank account, nobody can help you if you lose access to your BTC.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715485695
Hero Member
*
Offline Offline

Posts: 1715485695

View Profile Personal Message (Offline)

Ignore
1715485695
Reply with quote  #2

1715485695
Report to moderator
1715485695
Hero Member
*
Offline Offline

Posts: 1715485695

View Profile Personal Message (Offline)

Ignore
1715485695
Reply with quote  #2

1715485695
Report to moderator
1715485695
Hero Member
*
Offline Offline

Posts: 1715485695

View Profile Personal Message (Offline)

Ignore
1715485695
Reply with quote  #2

1715485695
Report to moderator
jhansen858
Sr. Member
****
Offline Offline

Activity: 364
Merit: 250


View Profile
June 19, 2011, 07:02:05 AM
 #2

I had a perfectly working script and now all it does is crank away forever never getting results back from mtgox.. I have spent over 3 hours trying to fix to no avail..


Hi forum: 1DDpiEt36VTJsiJunyBc3XtG6CcSAnsQ4p
phorensic
Hero Member
*****
Offline Offline

Activity: 630
Merit: 500



View Profile
June 19, 2011, 07:38:04 AM
 #3

I had a working file_get_contents script to show the last price.  Then my page started to run infinitely with no results yesterday.  Switched file_get_contents to the cURL method.  Now curl times out before getting any results, even though the command line curl works.  I don't know what happened, but all of a sudden I can't use their API!
redshark1802
Newbie
*
Offline Offline

Activity: 44
Merit: 0


View Profile
June 19, 2011, 07:52:08 AM
 #4

I had a working file_get_contents script to show the last price.  Then my page started to run infinitely with no results yesterday.  Switched file_get_contents to the cURL method.  Now curl times out before getting any results, even though the command line curl works.  I don't know what happened, but all of a sudden I can't use their API!

I have the same problems. I have no idea what is going wrong on their side.
Has anybody an alternative solution?

kind regards, redshark1802
de_bert (OP)
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
June 19, 2011, 08:23:11 AM
 #5

Well, I finally found the solution to my problem, and realized that the API description is just very misleading.
Instead of
Code:
https://mtgox.com/code/buyBTC.php?name=blah&pass=blah&amount=#&price=#
it should say
Code:
https://mtgox.com/code/buyBTC.php
with POST parameters name, pass, amount, price:

Code:
 $.ajax({
                type: 'POST',
                url: 'https://mtgox.com/code/sellBTC.php',
                dataType: 'json',
                data: {name: this.strUser,
                       pass: this.strPass,
                       amount: numAmount,
                       price: numPrice},
                success: this.onSellSuccess.bind(this, funCallback),
                error: this.onSellFailure.bind(this, funCallback)
            });

Ticker data, i.e. last price, should work, however you have to be careful to always use "https" - I had some issues where "http" would return an error, but not always...
jhansen858
Sr. Member
****
Offline Offline

Activity: 364
Merit: 250


View Profile
June 19, 2011, 09:41:02 AM
 #6

what if your just trying to pull pricing and not do transactions.

Hi forum: 1DDpiEt36VTJsiJunyBc3XtG6CcSAnsQ4p
redshark1802
Newbie
*
Offline Offline

Activity: 44
Merit: 0


View Profile
June 19, 2011, 01:30:25 PM
 #7

what if your just trying to pull pricing and not do transactions.

Hi,

that's my code:
Code:
$mtgoxJSON = file_get_contents("https://mtgox.com/code/data/ticker.php");
$mtgoxJSON = utf8_encode($mtgoxJSON);
$mtgoxJSON = json_decode($mtgoxJSON);

I tried various timeout options but not one is working.

regards, redshark1802
de_bert (OP)
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
June 19, 2011, 04:02:05 PM
 #8

There was another thread, i'm to lazy to look it up now, where they found that you have to supply some user agent string. Does not matter what, but you need to supply one.
Maybe your function does not do that?
redshark1802
Newbie
*
Offline Offline

Activity: 44
Merit: 0


View Profile
June 19, 2011, 04:27:59 PM
 #9

There was another thread, i'm to lazy to look it up now, where they found that you have to supply some user agent string. Does not matter what, but you need to supply one.
Maybe your function does not do that?

Thats right, it does not. But it worked, suddenly it just runs endless.
I havent changed anything, it must be a change withing mtgox.
Thanks for your help.

regards, redshark1802
de_bert (OP)
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
June 19, 2011, 06:21:17 PM
 #10

Thats right, it does not. But it worked, suddenly it just runs endless.
I havent changed anything, it must be a change withing mtgox.

Jup, I assume they did it because of the DDoS attacks - although I would guess this does not change a thing, really.
But they apparently really changed something, so you'll have to change your code.

That's exactly the problem with Mt. Gox - or let's say the biggest problem - they would not communicate if their life depended on it. Central change in the API? Why worry! Nobody needs to know...
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!