Bitcoin Forum
June 22, 2024, 09:35:20 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Instawallet API  (Read 861 times)
hamburger (OP)
Full Member
***
Offline Offline

Activity: 241
Merit: 107



View Profile WWW
August 08, 2011, 09:10:28 AM
Last edit: August 08, 2011, 09:31:58 AM by hamburger
 #1

Hi,

Do anyone have an example in PHP to a make a payment with the instawallet API?

This is the code that I use and it result in a 404: Not Found instead of the expected response such as {"successful": true, "message": "Sent 0.01 BTC to 14Z1mazY4HfysZyMaKudFr63EwHqQT2njz", "message_code": 0}

Code:

$url = "https://www.instawallet.org/api/v1/w/$wallet/payment?address=$address&amount=$amount";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Opera/9.23 (Windows NT 5.1; U; en)');
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
$result = curl_exec($ch);
echo $result;


More info on the API is available here: https://www.instawallet.org/static/api.html?v=e2406

Thank you,

Hamburger


Datacoin : DHZ6H91fsDoBHbdqED3ysCJJ2TUh3zRMZD
Krugercoin : Yz3A9sTMp2yh5QLuAL8YQyvS5PdjHRHkkf
payb.tc
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1000



View Profile
August 08, 2011, 09:15:20 AM
 #2

have you double-checked the $wallet var to make sure it contains what you expect? (not empty?)

just before your curl, echo or log $url and take a look at exactly how it's been formed.

also: it says on that instawallet page that the url you're trying to connect to should be done with a POST. so look at curl options and CURLOPT_POST:

curl_setopt($ch, CURLOPT_POST, 1);
payb.tc
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1000



View Profile
August 08, 2011, 09:27:04 AM
 #3

try this:

Code:
$url = "https://www.instawallet.org/api/v1/w/$wallet/payment";
$postdata=array('address'=>$address,'amount'=>$amount);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Opera/9.23 (Windows NT 5.1; U; en)');
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
$result = curl_exec($ch);
echo $result;
hamburger (OP)
Full Member
***
Offline Offline

Activity: 241
Merit: 107



View Profile WWW
August 08, 2011, 09:39:36 AM
 #4

Hi,

Post #3 work perfect.

Thank you,

Hamburger

Datacoin : DHZ6H91fsDoBHbdqED3ysCJJ2TUh3zRMZD
Krugercoin : Yz3A9sTMp2yh5QLuAL8YQyvS5PdjHRHkkf
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!