Author

Topic: BitInstant PHP API Example (Read 2525 times)

legendary
Activity: 1498
Merit: 1000
February 14, 2013, 12:40:28 AM
#23
BitInstant, for the love of god, fix your docs.

I couldn't agree more, I am glad I don't need there API
legendary
Activity: 1498
Merit: 1000
February 14, 2013, 12:34:42 AM
#20
I got it working here try this code
Code:






$data_string "{\"pay_method\":\"zipzap\",\"amount\":80.00,\"dest_exchange\":\"btc\",\"dest_account\":\"1FqWCdCdFeok2ifsfYbcFxwiC8pE7h9xhC\",\"notify_email\":\"[email protected]\",\"fName\":\"John\",\"lName\":\"Doe\", \"dob\":\"1985-01-01\"}";                                                                                
 
$ch curl_init('https://www.bitinstant.com/api/json/GetQuote');                                                                      
curl_setopt($chCURLOPT_CUSTOMREQUEST"POST");                                                                     
curl_setopt($chCURLOPT_POSTFIELDS$data_string);                                                                  
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);                                                                      
curl_setopt($chCURLOPT_HTTPHEADER, array(                                                                          
    
'Content-Type: application/json',                                                                                
    
'Content-Length: ' strlen($data_string))                                                                       
);                                                                                                                   
 
$result curl_exec($ch);
echo 
$result;
?>




and it returns

Code:
{"NotifyEmail": "[email protected]", "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"}
sr. member
Activity: 798
Merit: 251
February 24, 2013, 09:59:48 AM
#18
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.
qrs
newbie
Activity: 47
Merit: 0
February 24, 2013, 08:03:24 AM
#17
I have full script The Bitcoin Shopping Cart Interface in PHP, do you want it?
sr. member
Activity: 798
Merit: 251
February 14, 2013, 01:06:54 AM
#16
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.
hero member
Activity: 812
Merit: 1000
February 14, 2013, 12:37:27 AM
#15
so the conclusion is that you needed to be posting a mandatory field, d.o.b., yet the error message was too vague.
sr. member
Activity: 798
Merit: 251
February 14, 2013, 12:35:57 AM
#14
sr. member
Activity: 798
Merit: 251
February 14, 2013, 12:30:04 AM
#13
Seems to be working now...will post sample code based on the help in this thread in a few minutes.  Thanks guys!
hero member
Activity: 812
Merit: 1000
February 14, 2013, 12:26:20 AM
#12
Code:
$data = array(
      "pay_method" => "zipzap",
      "amount" => 80.00,
      "dest_exchange" => "btc",
      "dest_account" => "1FqWCdCdFeok2ifsfYbcFxwiC8pE7h9xhC",
      "notify_email" => "[email protected]",
      "fName" => "John",
      "lName" => "Doe"
);
$data_string = json_encode($data);
hero member
Activity: 812
Merit: 1000
February 14, 2013, 12:22:06 AM
#11
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).
sr. member
Activity: 798
Merit: 251
February 14, 2013, 12:10:38 AM
#10
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
Code:
curl_setopt($ch, CURLOPT_POSTFIELDS,"{\"pay_method\":\"zipzap\",\"amount\":80.00,\"dest_exchange\":\"btc\",\"dest_account\":\"1FqWCdCdFeok2ifsfYbcFxwiC8pE7h9xhC\",\"notify_email\":\"[email protected]\"}");

Yes then, it appears that I'm sending it correctly.  It just doesn't work.
sr. member
Activity: 798
Merit: 251
February 13, 2013, 11:58:06 PM
#9
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.
sr. member
Activity: 798
Merit: 251
February 13, 2013, 11:51:59 PM
#8
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.
hero member
Activity: 812
Merit: 1000
February 13, 2013, 11:49:51 PM
#7
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?
sr. member
Activity: 798
Merit: 251
February 13, 2013, 11:47:42 PM
#6
Why is your amount a string it should be
Code:
{"pay_method":"zipzap","amount":80,"dest_exchange":"btc","dest_account":"1FqWCdCdFeok2ifsfYbcFxwiC8pE7h9xhC","notify_email":"[email protected]"}

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.
sr. member
Activity: 798
Merit: 251
February 13, 2013, 11:41:47 PM
#5
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":"[email protected]"}

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?
BCB
vip
Activity: 1078
Merit: 1002
BCJ
October 17, 2012, 09:30:28 AM
#4
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. 
hero member
Activity: 721
Merit: 503
October 17, 2012, 08:47:02 AM
#3
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 [email protected] outlining what you're trying to do with our API and i'll help you out.
legendary
Activity: 1498
Merit: 1000
October 10, 2012, 09:46:28 PM
#2
just use curl on this URL https://www.bitinstant.com/api/json/ not too difficult
member
Activity: 110
Merit: 10
#2985 for 60 GH/S Single
October 10, 2012, 07:46:38 PM
#1
Does anyone have a working PHP script with bitinstant's API? If so will you please share.

Thanks!
Jump to: