在PHP中获取最新的 steem_per_mvests | Get newest steem_per_mvests in PHP

in #cn-dev6 years ago
<?php
function steem_per_mvests() {
    $url = 'https://api.steemit.com';

    $data = '{"jsonrpc":"2.0", "method":"database_api.get_dynamic_global_properties", "id":1}';
    $options = array(
      'http' =>
        array(
          'header' => "Content-Type: application/json\r\n".
                      "Content-Length: ".strlen($data)."\r\n".
                      "User-Agent:SteemMention/1.0\r\n",
          'method'  => 'POST',
          'content' => $data,
        )
    );
    $context  = stream_context_create($options);
    try {
        $result = file_get_contents($url, false, $context);
        $r = json_decode($result, true);
        $result = $r['result'];
    } catch (\Exception $e) {
        return false;
    }
    return $result['total_vesting_fund_steem']['amount'] / ($result['total_vesting_shares']['amount'] / 1e6);
}

function vests_to_sp($vests) {
    $steem_per_mvests = steem_per_mvests();
    if ($steem_per_mvests) {
        return $vests / 1e6 * $steem_per_mvests;
    } else {
        return false;
    }
}

欢迎使用 SteemEditor 来编写文章,获取 @steemeditor.bot 的大力点赞!


欢迎使用 SteemMention 获取最新的 Steem 回复提醒。


感谢你的阅读,我是中文区见证人之一,欢迎通过 SteemConnect 来给我投票,或者打开 https://steemit.com/~witnesses/ 页面,输入 ety001 进行投票。

2.gif

中文区的见证人目前有:
支持一下他们(按字母顺序),一人可以有30票


Thank you for reading. I'm a witness. I would really appreciate your witness vote! You can vote by SteemConnect. Or open https://steemit.com/~witnesses page, input ety001 to vote.

2.gif

Sort:  

That's magnificent and simple

Coin Marketplace

STEEM 0.18
TRX 0.16
JST 0.030
BTC 67421.82
ETH 2623.68
USDT 1.00
SBD 2.68