所以我試圖通過使用 curl 的 API 將來自網站的資訊顯示到我的網站上。
而且我根本不知道卷曲:(
所以這就是我必須從源網站獲得的:
curl -H "IHOSTMN-API-KEY:YourIhostmnApiKeyHere" -X GET "https://ihostmn.com/api/v1/sharing/user/list_all_deposits"
它應該給出這樣的回應:
{
"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": ""
}
我已經創建了我的 php 網頁,但無法使其作業,這是寫的:
curl -H "IHOSTMN-API-KEY:xxxxxxxxxxxxxxxxxxxxxxxxx" -X GET "https://ihostmn.com/api/v1/sharing/user/list_all_deposits"
$obj = json_decode($result);
echo $obj[0]->deposits;
希望你們中的一個人能夠為我指明正確的方向,并感謝您抽出時間提供幫助。
標記
uj5u.com熱心網友回復:
嘗試這樣的事情
<?
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://ihostmn.com/api/v1/sharing/user/list_all_deposits');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$headers = array();
$headers[] = 'Ihostmn-Api-Key: YourIhostmnApiKeyHere';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$obj = json_decode($result);
print_r($obj->result->deposits);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
您將 [] 用于陣列,將箭頭用于物件。
我無法測驗 API,但這應該會給你一個先機。
有用的鏈接:cURL
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/459344.html
