JsonRpc.php 649 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 14/04/2017
  6. * Time: 20:11
  7. */
  8. namespace app\common\services;
  9. use JsonRPC\Client;
  10. /**
  11. * Class JsonRpc
  12. *
  13. * @package app\common\services
  14. */
  15. class JsonRpc
  16. {
  17. protected $url = '';
  18. public function __construct($url = '')
  19. {
  20. $this->url = $url;
  21. if(!$this->url){
  22. $this->url = \Config::get('rpc.client.url');
  23. }
  24. }
  25. public function client($method, $params = [])
  26. {
  27. $client = new Client($this->url);
  28. //$client->authentication('jan','123');
  29. return $client->execute($method, $params);
  30. }
  31. }