Bitcoin Forum
May 27, 2024, 07:42:10 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Any API guru's here ?  (Read 51 times)
The_Trader (OP)
Member
**
Offline Offline

Activity: 180
Merit: 52


View Profile
April 17, 2022, 07:48:14 PM
 #1

This is an official IHost example and the address given are fictitious

Real quick one so I am trying to get a specific bit of information from an API.

It's an IHost api I am calling and i get a response similar to this:

Code:
{
    "result": {
        "deposits": [
            {
                "deposit_id": 36,
                "share_id": 2,
                "current_amount": 53.077553,
                "total_deposited": 24.91567,
                "total_earned": 28.146885,
                "withdraw_address": "GcUgnY5fFwTv9ef8rsggdxbdQzLEUxpp4c",
                "deposit_address": "GfUgnY5sFwTf9ez8rovtdxdEQzLcbxpb4c"
            },
            {
                "deposit_id": 37,
                "share_id": 5,
                "current_amount": 885.9591,
                "total_deposited": 521.92,
                "total_earned": 472.30566,
                "withdraw_address": "gHWHPs21H8UsSNcbfWxvn5XssAxFkcuZYe",
                "deposit_address": "g4sbWWtD3tf16Dsd8wiaJkar3zhJ82qNKP"
            },
            {
                "deposit_id": 38,
                "share_id": 6,
                "current_amount": 754.5115,
                "total_deposited": 548.52997,
                "total_earned": 416.25214,
                "withdraw_address": "LLqWFFJkNSog6VwsbPWEWE4KcXJrzB6t1K",
                "deposit_address": "LW5Vbt1gEkvVQzfVcpLmidLPpcED1Yp3yu"
            }
        ]
    },
    "error": ""
}

By using
Code:
print_r($obj->result->deposits);

BUT how do I just get a specific bit of info for example if I want to display total_earned on deposit ID38 what would I have to alter
Code:
print_r($obj->result->deposits);
to to make it work ?

Many Thanks for any help offered Smiley

TT
vv181
Legendary
*
Offline Offline

Activity: 1932
Merit: 1273


View Profile
April 17, 2022, 09:21:38 PM
 #2

I don't know about PHP.

But does the nested array only has 3 items. If that is so, maybe you can directly access the index. Or if it is not, reiterate the array to print the value based on the ID.

Anyway, you should have posted this question on Stackoverflow.
The_Trader (OP)
Member
**
Offline Offline

Activity: 180
Merit: 52


View Profile
April 17, 2022, 09:26:40 PM
 #3

I don't know about PHP.

But does the nested array only has 3 items. If that is so, maybe you can directly access the index. Or if it is not, reiterate the array to print the value based on the ID.

Anyway, you should have posted this question on Stackoverflow.

I did post it their and it got hidden, telling me it was lacking research which is nonsense as I have been trying to solve this all day

Its the attaching the id number im having issues with I have tried all sorts like
Code:
print_r($obj->result->deposits->deposit_id->38->total_earned);
but it wont work Sad
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!