Author

Topic: XAPO PHP (Read 552 times)

legendary
Activity: 1059
Merit: 1020
September 24, 2016, 10:29:19 AM
#3
You shall use the original XAPO PHP library script: https://github.com/xapo/php-sdk.
The example is in 'XapoCreditAPITest.php' and its easy to use.

Cheers
Salmen
legendary
Activity: 2016
Merit: 1107
September 24, 2016, 05:02:26 AM
#2
why don't you use the ready made xapo faucet script
it already has the xapo payment daemon,no need to code from scratch
check the topics here:
https://bitcointalksearch.org/topic/a-guide-for-building-xapo-faucets-download-script-1365803
https://bitcointalksearch.org/topic/new-xapo-faucet-script-with-full-updates-download-1585991
https://bitcointalksearch.org/topic/minifaucet-script-a-myfaucet-replacement-333748

use search to find more info and good luck with your faucet
newbie
Activity: 1
Merit: 0
September 21, 2016, 01:44:48 PM
#1
Hello, I am trying to develop a faucet so I need to send satoshis to my users. I have created the XAPO APP. I have secret ID and APP ID.
I can get token but when I try to send satoshis it shows this:
POST TRANSACTION RESPONSE
string(60) "{"error_description": "Invalid account", "error_code": 7003}"

I must say that I can only send to email xapo account (It is default in my XAPO APP).

This is the code that I am using.

 
Quote

function GetAuthToken() {
   
    $sYourRedirectUri = "-------------------------";
    $sAPPID = "----------------";
    $sAPPSecret = "---------------------";
   
    $sPostFields = "client_credentials&redirect_uri=" . $sYourRedirectUri;
    $sAuthCode = base64_encode($sAPPID . ":" . $sAPPSecret);
   
    $ch = curl_init();
   
    curl_setopt($ch, CURLOPT_URL, "https://v2.api.xapo.com/oauth2/token");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
   
    curl_setopt($ch, CURLOPT_POST, TRUE);
   
    curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=" . $sPostFields);
   
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
      "Content-Type: application/x-www-form-urlencoded",
      "Authorization: Basic " . $sAuthCode
    ));
   
    $response = curl_exec($ch);
    curl_close($ch);
   
    return $response;
}

$sToken = json_decode(GetAuthToken());
  $token=$sToken->access_token;
  $addr="----------------------"; //[email protected]
  $myaccountid="-------"; //1234567
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.xapo.com/accounts/".$addr."/transactions");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{
  \"to\": \"".$addr."\",
  \"amount\": 0.0000001,
  \"currency\": \"BTC\",
  \"notes\": \"Testing\",
  \"type\": \"pay\"
}");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  "Content-Type: application/json",
  "Authorization: Bearer ".$token
));
$response = curl_exec($ch);
curl_close($ch);
echo '
POST TRANSACTION RESPONSE
';
var_dump($response);
echo '
POST TRANSACTION END
';
echo date('l jS \of F Y h:i:s A');


Can you help me guys? Thank you so much
Jump to: