PHP sample code

This sample contains PHP example for connecting FRUITS API and JSON response

Sample code for connecting FRUITS API

<?php
$url = 'https://fwallet.net/fruits?requestType=getAccount&account=FRUITS-CNQB-X85V-HJNK-C2G5-CVJK-M6SQ';

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Accept: application/json'
));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_POSTREDIR, 3);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0.5);
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
$result = curl_exec($ch);
curl_close($ch);
$json_feed = json_decode($result, true);

echo $result;

JSON response

{
  "balanceNQT": "4653438137",
  "unconfirmedBalanceNQT": "3653438137",
  "forgedBalanceNQT": "120250000",
  "guaranteedBalanceNQT": "4653438137",
  "accountRS": "FRUITS-CNQB-X85V-HJNK-C2G5-CVJK-M6SQ",
  "accountRSExtended": "FRUITS-CNQB-X85V-HJNK-C2G5-CVJK-M6SQ-3KFMRBIORXJQ3USLK6FZ8D4SCRI1K8CA0YB5MAZ7I5QM1TXW1F",
  "assetBalances": [
    {
      "asset": "1722657592827525362",
      "balanceQNT": "820000000"
    },
    {
      "asset": "16174957441139110419",
      "balanceQNT": "450000"
    },
    {
      "asset": "9121771018178014707",
      "balanceQNT": "1000"
    }
  ],
  "unconfirmedAssetBalances": [
    {
      "asset": "1722657592827525362",
      "unconfirmedBalanceQNT": "820000000"
    },
    {
      "asset": "16174957441139110419",
      "unconfirmedBalanceQNT": "100000"
    },
    {
      "asset": "9121771018178014707",
      "unconfirmedBalanceQNT": "1000"
    }
  ],
  "requestProcessingTime": 1
}

Last updated