Bitcoin Forum

Other => Beginners & Help => Topic started by: tenbatsu on June 18, 2011, 06:37:14 AM



Title: Has the API stopped responding for anyone else? [PHP question]
Post by: tenbatsu on June 18, 2011, 06:37:14 AM
I used to be able to query the mtgox ticker with the following code:

Code:
 
  $c = curl_init();
  curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($c, CURLOPT_URL, 'https://mtgox.com/code/data/ticker.php');
  curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
  $result = curl_exec($c);
  curl_close($c);

2~3 hours ago that stopped working.  I tried saving the certificate so I could query as follows:

Code:
  $c = curl_init();
  curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($c, CURLOPT_URL, 'https://mtgox.com/code/data/ticker.php');
  curl_setopt($c, CURLOPT_SSL_VERIFYPEER, true);
  curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2);
  curl_setopt($c, CURLOPT_CAINFO, "./CAcerts/www.mtgox.com");
  $result = curl_exec($c);
  curl_close($c);

That didn't work either.  Did the API change somehow or is my code simply off?


Title: Re: Has the API stopped responding for anyone else? [PHP question]
Post by: tenbatsu on June 18, 2011, 09:27:09 AM
Nevermind, seems to be working again.


Title: Re: Has the API stopped responding for anyone else? [PHP question]
Post by: lightbox on June 18, 2011, 04:55:28 PM
Not working again for me :( for about the past hour or so...

but wget works fine, so something with php/curl is causing the problem

use im using SSL_VERIFYPEER  FALSE  and SSL_VERIFYHOST  FALSE



Title: Re: Has the API stopped responding for anyone else? [PHP question]
Post by: lightbox on June 18, 2011, 05:49:23 PM
Solved, MagicalTux must have changed something, because now USERAGENT is required.

curl_setopt($ch, CURLOPT_USERAGENT, "curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18");

did the trick





Title: Re: Has the API stopped responding for anyone else? [PHP question]
Post by: de_bert on June 18, 2011, 05:52:14 PM
Seeing how you have some experience with the mt. gox api, could you please have a look at my issue?
http://forum.bitcoin.org/index.php?topic=18934.0

Thanks!


Title: Re: Has the API stopped responding for anyone else? [PHP question]
Post by: philipp on June 18, 2011, 05:54:22 PM
Same problem here. libcurl doesn't work, but plain curl does. Will try setting the useragent.

Philipp


Title: Re: Has the API stopped responding for anyone else? [PHP question]
Post by: philipp on June 18, 2011, 05:56:33 PM
Solved, MagicalTux must have changed something, because now USERAGENT is required.

curl_setopt($ch, CURLOPT_USERAGENT, "curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18");

did the trick





Yeah. For the C programmers out there:

curl_easy_setopt(curl, CURLOPT_USERAGENT, "Some bot.");

will do the trick.

Philipp



Title: Re: Has the API stopped responding for anyone else? [PHP question]
Post by: Clark on June 18, 2011, 10:27:09 PM
Thanks so much for posting this! My services had bombed out today due to this change.

It would be nice for MagicalTux to create a developer mailing list or forum thread to keep us aware of this kind of thing...


Title: Re: Has the API stopped responding for anyone else? [PHP question]
Post by: tenbatsu on June 19, 2011, 12:41:11 AM
Quote
It would be nice for MagicalTux to create a developer mailing list or forum thread to keep us aware of this kind of thing...

That or a page describing the API would be awesome.


Title: Re: Has the API stopped responding for anyone else? [PHP question]
Post by: Dirt Rider on June 19, 2011, 05:43:01 AM
Solved, MagicalTux must have changed something, because now USERAGENT is required.

curl_setopt($ch, CURLOPT_USERAGENT, "curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18");

did the trick

I usually don't even consider "tips" but damn lightbox, you just solved a HUGE headache for me!

Donation address please!


Title: Re: Has the API stopped responding for anyone else? [PHP question]
Post by: lightbox on June 24, 2011, 01:39:25 AM
Solved, MagicalTux must have changed something, because now USERAGENT is required.

curl_setopt($ch, CURLOPT_USERAGENT, "curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18");

did the trick

I usually don't even consider "tips" but damn lightbox, you just solved a HUGE headache for me!

Donation address please!

Lol glad i could help, i only pounded my head on the desk for about an hour to figure it out :p  now if only mtgox would get back up so I can finish the tweaks on the bot!

Thanks for the offer of a tip! here's an address: 1NgFb2LyyLvGaSHWasi2sYsn7iXDzDqzvb