Bitcoin Forum
December 04, 2016, 08:26:55 PM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Mt. Gox API problems  (Read 1262 times)
de_bert
Jr. Member
*
Offline Offline

Activity: 42


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

Posts: 1480883215

View Profile Personal Message (Offline)

Ignore
1480883215
Reply with quote  #2

1480883215
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
jhansen858
Sr. Member
****
Offline Offline

Activity: 336


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



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

Activity: 44


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

If the post above is something worth to you, please consider donating Wink.
1HYek9jXvbMDYyYwN7rxy9i3oDWgCYhATx
de_bert
Jr. Member
*
Offline Offline

Activity: 42


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: 336


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

Activity: 44


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

If the post above is something worth to you, please consider donating Wink.
1HYek9jXvbMDYyYwN7rxy9i3oDWgCYhATx
de_bert
Jr. Member
*
Offline Offline

Activity: 42


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

Activity: 44


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

If the post above is something worth to you, please consider donating Wink.
1HYek9jXvbMDYyYwN7rxy9i3oDWgCYhATx
de_bert
Jr. Member
*
Offline Offline

Activity: 42


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:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!