demo.php 695 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. require_once("./index.php");
  3. //binary file path
  4. $binPath = XASSET_PATH . 'tools/xasset-cli/xasset-cli';
  5. $crypto = new EcdsaCrypto($binPath);
  6. $config = new XassetConfig($crypto);
  7. $appId = 0;
  8. $ak = 'xxx';
  9. $sk = 'xxx';
  10. $config->setCredentials($appId, $ak, $sk);
  11. $config->endPoint = "http://120.48.16.137:8360";
  12. $xHandle = new XassetClient($config);
  13. //生成新的account
  14. $ac = New Account($binPath);
  15. $account = $ac->createAccount();
  16. //使用现有account
  17. /*$addr = '';
  18. $pubKey = '';
  19. $privtKey = '';
  20. $account = array(
  21. 'address' => $addr,
  22. 'public_key' => $pubKey,
  23. 'private_key' => $privtKey,
  24. );*/
  25. //文件相关接口
  26. $stoken = $xHandle->getStoken($account);
  27. var_dump($stoken);