Simple PHP Script

in #cn7 years ago (edited)


<?
class Steemd
{
   private $ch;
   function __construct(){
     $this->ch = curl_init();
     curl_setopt($this->ch, CURLOPT_URL, 'https://steemd.steemit.com');
     curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, TRUE);
   }

   function __destruct() {
     curl_close($this->ch);
   }

   private function json_rpc_body($method, $params){
       $request = array(
           "jsonrpc" => "2.0",
           "method" => $method,
           "params" => $params,
           "id" => 0
           );
       return json_encode($request);
   }

   public function exec($method, $params = array()) {
       $data = $this->json_rpc_body($method, $params);
       curl_setopt($this->ch, CURLOPT_POSTFIELDS, $data);
       $response = curl_exec($this->ch);
       $response = json_decode($response, true);
       if (array_key_exists('error', $response)) {
         var_dump($response['error']);
         die();
       }
       return $response['result'];
   }

   public function get_account($account){
       $result = $this->exec('get_accounts', [[$account]]);
       return $result;
   }
}

$steemd = new Steemd;
echo('<pre>');
print_r($steemd->exec(get_chain_properties,[]));
print_r($steemd->get_account('oflyhigh'));
echo('</pre>');

//unset($steemd);
?>
Sort:  

Hi. I am a volunteer bot for @resteembot that upvoted you.
Your post was chosen at random, as part of the advertisment campaign for @resteembot.
@resteembot is meant to help minnows get noticed by re-steeming their posts


To use the bot, one must follow it for at least 3 hours, and then make a transaction where the memo is the url of the post.
If you want to learn more - read the introduction post of @resteembot.
If you want help spread the word - read the advertisment program post.


Steem ON!

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.030
BTC 65702.61
ETH 3485.24
USDT 1.00
SBD 2.51