brucegregory (OP)
Member
Offline
Activity: 110
Merit: 10
#2985 for 60 GH/S Single
|
|
October 11, 2012, 12:46:38 AM |
|
Does anyone have a working PHP script with bitinstant's API? If so will you please share.
Thanks!
|
|
|
|
|
Gareth Nelson
|
|
October 17, 2012, 01:47:02 PM |
|
Does anyone have a working PHP script with bitinstant's API? If so will you please share.
Thanks!
If you still have a need for this then drop an email to support@bitinstant.com outlining what you're trying to do with our API and i'll help you out.
|
|
|
|
BCB
CTG
VIP
Legendary
Offline
Activity: 1078
Merit: 1002
BCJ
|
|
October 17, 2012, 02:30:28 PM |
|
I started building a php wrapper a while ago but the documentation was so confusing I abandoned it. Let me know what calls you are looking to make and I'll see if I can dig it up.
|
|
|
|
crazylikeafox
|
|
February 14, 2013, 04:41:47 AM |
|
I started building a php wrapper a while ago but the documentation was so confusing I abandoned it. Let me know what calls you are looking to make and I'll see if I can dig it up.
The documentation is atrocious, and if anyone is successfully using their API and can answer my question, I'd be forever grateful. Blockchain.info's implementation of the Bitinstant API (the "Deposit With Cash" function) has been broken for 3 days, which is probably a bad sign. To get a quote, we're supposed to send along the user's birthday, and the documentation says "User's birthday in the following format:" and ends there. The format isn't specified. I could probably guess the proper format if the server would accept anything at all, but unfortunately I can't get that far. When I send a properly-encoded JSON request to: https://www.bitinstant.com/api/json/GetQuote/ (to get a quote) With a post body of: {"pay_method":"zipzap","amount":80,"dest_exchange":"btc","dest_account":"1FqWCdCdFeok2ifsfYbcFxwiC8pE7h9xhC","notify_email":" test@example.com"} It returns: {"error": "Update your code - pass parameters as the POST body, JSON encoded"} No matter what you do. Can anyone shed any light on this?
|
|
|
|
crazylikeafox
|
|
February 14, 2013, 04:47:42 AM |
|
Why is your amount a string it should be {"pay_method":"zipzap","amount":80,"dest_exchange":"btc","dest_account":"1FqWCdCdFeok2ifsfYbcFxwiC8pE7h9xhC","notify_email":"test@example.com"}
Forgot to mention that. I've tried it both ways, and it doesn't matter. Returns the same error message. I was grasping at straws when I did that.
|
|
|
|
payb.tc
|
|
February 14, 2013, 04:49:51 AM |
|
what do you mean by "post body" ?
how are you encoding it? are you putting that JSON in a string var?
are you using curl?
|
|
|
|
crazylikeafox
|
|
February 14, 2013, 04:51:59 AM |
|
what do you mean by "post body" ?
how are you encoding it?
are you using curl?
I've tried it in the above format with both cURL and in a Delphi program. Doesn't matter, same result. You would think they would ask for a named Post field, like "jsondata={json stuff}" but the documentation disputes that and doesn't list any field name.
|
|
|
|
crazylikeafox
|
|
February 14, 2013, 04:58:06 AM |
|
Did you make sure to set the header as "application/json" for the content type? Also make sure your not sending it as a post parameter but your actually write it to the url
I am using application/json but could you clarify what you mean by "make sure your not sending it as a post parameter but your actually write it to the url"? Thanks for the help.
|
|
|
|
crazylikeafox
|
|
February 14, 2013, 05:10:38 AM |
|
Did you make sure to set the header as "application/json" for the content type? Also make sure your not sending it as a post parameter but your actually write it to the url
I am using application/json but could you clarify what you mean by "make sure your not sending it as a post parameter but your actually write it to the url"? Thanks for the help. So instead of sending an array you send the data like curl_setopt($ch, CURLOPT_POSTFIELDS,"{\"pay_method\":\"zipzap\",\"amount\":80.00,\"dest_exchange\":\"btc\",\"dest_account\":\"1FqWCdCdFeok2ifsfYbcFxwiC8pE7h9xhC\",\"notify_email\":\"test@example.com\"}");
Yes then, it appears that I'm sending it correctly. It just doesn't work.
|
|
|
|
payb.tc
|
|
February 14, 2013, 05:22:06 AM |
|
could you try letting PHP generate the json instead?
and if so, output the $data_string so that we can see what the difference are (if any).
|
|
|
|
payb.tc
|
|
February 14, 2013, 05:26:20 AM |
|
$data = array( "pay_method" => "zipzap", "amount" => 80.00, "dest_exchange" => "btc", "dest_account" => "1FqWCdCdFeok2ifsfYbcFxwiC8pE7h9xhC", "notify_email" => "test@example.com", "fName" => "John", "lName" => "Doe" ); $data_string = json_encode($data);
|
|
|
|
crazylikeafox
|
|
February 14, 2013, 05:30:04 AM |
|
Seems to be working now...will post sample code based on the help in this thread in a few minutes. Thanks guys!
|
|
|
|
crazylikeafox
|
|
February 14, 2013, 05:35:57 AM |
|
I got it working here try this code <!DOCTYPE HTML> <html> <head> <title></title> </head> <body> <?php $data_string = "{\"pay_method\":\"zipzap\",\"amount\":80.00,\"dest_exchange\":\"btc\",\"dest_account\":\"1FqWCdCdFeok2ifsfYbcFxwiC8pE7h9xhC\",\"notify_email\":\"test@example.com\",\"fName\":\"John\",\"lName\":\"Doe\", \"dob\":\"1985-01-01\"}"; $ch = curl_init('https://www.bitinstant.com/api/json/GetQuote'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string)) ); $result = curl_exec($ch); echo $result; ?> </body> </html>
and it returns {"NotifyEmail": "test@example.com", "ReferID": "None", "FirstName": "Doe", "DestExchange": "btc", "PayMethod": "zipzap", "LastName": "1985-01-01", "ZipZapCustomerLang": "en", "ExchangeName": "Bitcoin Address", "ZipZapCustomerCountry": "John", "ZipZapMerchantOrderID": "7c3c13a8-fbfa-49db-9e4d-a181343aec87", "DestAccount": "1FqWCdCdFeok2ifsfYbcFxwiC8pE7h9xhC", "eventtype": "Quote for new transaction", "ExpectedMaxDeliveryTime": "240.0", "ZipZapMerchantCustomerID": "3610", "OurRate": "3.99%%", "SneakPreviewUser": "129.49.21.91", "AmountPaidByClientUSD": "80.0", "expires": "1360823739.58", "GuaranteedDeliveryTime": "3600.0", "EventID": "ac10fa24-daaf-461f-9b70-1b8737be95af", "QuoteID": "ece8fa32-724b-4145-bfa4-fbeaa3592e83", "AmountCreditedToClientAccountUSD": "76.808", "dob": "", "EventSentAt": "1360820139.58", "ZipZapPassthru": "ece8fa32-724b-4145-bfa4-fbeaa3592e83"}
I just realized the same thing. Thank you so much for the help! BitInstant, for the love of god, fix your docs.
|
|
|
|
payb.tc
|
|
February 14, 2013, 05:37:27 AM |
|
so the conclusion is that you needed to be posting a mandatory field, d.o.b., yet the error message was too vague.
|
|
|
|
crazylikeafox
|
|
February 14, 2013, 06:06:54 AM |
|
so the conclusion is that you needed to be posting a mandatory field, d.o.b., yet the error message was too vague.
Actually, no. It does come back with a proper error message saying the format that the DOB must be in once you get to the point where it will accept the data. I haven't yet analyzed it enough to tell the functional differences between my code and the working code, so I don't have a conclusion yet as to what was going wrong. They were incredibly similar.
|
|
|
|
qrs
Newbie
Offline
Activity: 47
Merit: 0
|
|
February 24, 2013, 01:03:24 PM |
|
I have full script The Bitcoin Shopping Cart Interface in PHP, do you want it?
|
|
|
|
crazylikeafox
|
|
February 24, 2013, 02:59:48 PM |
|
I have full script The Bitcoin Shopping Cart Interface in PHP, do you want it?
Thanks, I would love it if you could PM me a link. Too bad BitInstant is out of commission at the moment and not communicating what's going on, but hopefully they'll be back soon.
|
|
|
|
|