FRUITS API Document
  • FRUITS API Document
  • Java sample code
  • PHP sample code
  • Creating Unsigned Transactions
  • Create Transaction Request
  • Create Transaction Response
  • SERVER INFORMATION
    • Get Blockchain Status
    • Get My Info
    • Get State
    • Get Time
  • ACCOUNT
    • Get Account
    • Get Account Blocks
    • Get Balance
    • Send FRTS
    • Send FRTS Multi
    • Set Account Info
  • TRANSACTION
    • Broadcast Transaction
    • Calculate Full Hash
    • Get Transaction
  • BLOCK
    • Get Block
    • Get Block Id
    • Get Blocks
  • Process flowchart
    • FRTS, token send/receive flow
    • FRUITS Wallet connect flow
  • Create & Active Account
    • Coding Guidelines in Java
    • Coding Guidelines in JS
  • FRUITS Node API For Single NFT
    • Create NFT Smart Contract
    • Mint NFT
    • Transfer NFT
    • Place a sell order
    • Cancel a sell order
    • Buy NFT
    • Get NFT By URI
    • Get List of NFTs by Account
    • Get List of NFTs for sale
    • Get List of NFTs By Smart Contract
  • FRUITS Node API For multiple NFT
    • Create NFT Smart Contract
    • Mint NFT
    • Transfer NFT
    • Place a sell order
    • Cancel a sell order
    • Buy NFT
    • Get Multiple Token By Account
    • Get Multiple Token By Contract
    • Get Multiple Token By Owners
    • Get Multiple Token By Uri
Powered by GitBook
On this page

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
}
PreviousJava sample codeNextCreating Unsigned Transactions

Last updated 1 year ago