Bitcoin Forum
May 02, 2024, 02:47:21 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: BitInstant PHP API Example  (Read 2499 times)
brucegregory (OP)
Member
**
Offline Offline

Activity: 110
Merit: 10


#2985 for 60 GH/S Single


View Profile
October 11, 2012, 12:46:38 AM
 #1

Does anyone have a working PHP script with bitinstant's API? If so will you please share.

Thanks!

1714618041
Hero Member
*
Offline Offline

Posts: 1714618041

View Profile Personal Message (Offline)

Ignore
1714618041
Reply with quote  #2

1714618041
Report to moderator
1714618041
Hero Member
*
Offline Offline

Posts: 1714618041

View Profile Personal Message (Offline)

Ignore
1714618041
Reply with quote  #2

1714618041
Report to moderator
1714618041
Hero Member
*
Offline Offline

Posts: 1714618041

View Profile Personal Message (Offline)

Ignore
1714618041
Reply with quote  #2

1714618041
Report to moderator
You can see the statistics of your reports to moderators on the "Report to moderator" pages.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
gweedo
Legendary
*
Offline Offline

Activity: 1498
Merit: 1000


View Profile
October 11, 2012, 02:46:28 AM
 #2

just use curl on this URL https://www.bitinstant.com/api/json/<method> not too difficult
Gareth Nelson
Hero Member
*****
Offline Offline

Activity: 721
Merit: 503


View Profile
October 17, 2012, 01:47:02 PM
 #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 support@bitinstant.com outlining what you're trying to do with our API and i'll help you out.
BCB
CTG
VIP
Legendary
*
Offline Offline

Activity: 1078
Merit: 1002


BCJ


View Profile
October 17, 2012, 02:30:28 PM
 #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. 
crazylikeafox
Sr. Member
****
Offline Offline

Activity: 798
Merit: 251



View Profile
February 14, 2013, 04:41:47 AM
 #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":"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
Sr. Member
****
Offline Offline

Activity: 798
Merit: 251



View Profile
February 14, 2013, 04:47:42 AM
 #6

Why is your amount a string it should be
Code:
{"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
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1000



View Profile
February 14, 2013, 04:49:51 AM
 #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?
crazylikeafox
Sr. Member
****
Offline Offline

Activity: 798
Merit: 251



View Profile
February 14, 2013, 04:51:59 AM
 #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.
crazylikeafox
Sr. Member
****
Offline Offline

Activity: 798
Merit: 251



View Profile
February 14, 2013, 04:58:06 AM
 #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.
crazylikeafox
Sr. Member
****
Offline Offline

Activity: 798
Merit: 251



View Profile
February 14, 2013, 05: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\":\"test@example.com\"}");

Yes then, it appears that I'm sending it correctly.  It just doesn't work.
payb.tc
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1000



View Profile
February 14, 2013, 05: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).
payb.tc
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1000



View Profile
February 14, 2013, 05:26:20 AM
 #12

Code:
$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
Sr. Member
****
Offline Offline

Activity: 798
Merit: 251



View Profile
February 14, 2013, 05: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!
crazylikeafox
Sr. Member
****
Offline Offline

Activity: 798
Merit: 251



View Profile
February 14, 2013, 05:35:57 AM
 #14

I got it working here try this code
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($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;
?>

</body>
</html>

and it returns

Code:
{"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
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1000



View Profile
February 14, 2013, 05: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.
crazylikeafox
Sr. Member
****
Offline Offline

Activity: 798
Merit: 251



View Profile
February 14, 2013, 06: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.
qrs
Newbie
*
Offline Offline

Activity: 47
Merit: 0



View Profile
February 24, 2013, 01:03:24 PM
 #17

I have full script The Bitcoin Shopping Cart Interface in PHP, do you want it?
crazylikeafox
Sr. Member
****
Offline Offline

Activity: 798
Merit: 251



View Profile
February 24, 2013, 02:59:48 PM
 #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.
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!