You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

35 lines
1.2 KiB

  1. <?php
  2. namespace JPush;
  3. use InvalidArgumentException;
  4. class Client {
  5. private $appKey;
  6. private $masterSecret;
  7. private $retryTimes;
  8. private $logFile;
  9. public function __construct($appKey, $masterSecret, $logFile=Config::DEFAULT_LOG_FILE, $retryTimes=Config::DEFAULT_MAX_RETRY_TIMES) {
  10. if (!is_string($appKey) || !is_string($masterSecret)) {
  11. throw new InvalidArgumentException("Invalid appKey or masterSecret");
  12. }
  13. $this->appKey = $appKey;
  14. $this->masterSecret = $masterSecret;
  15. if (!is_null($retryTimes)) {
  16. $this->retryTimes = $retryTimes;
  17. } else {
  18. $this->retryTimes = 1;
  19. }
  20. $this->logFile = $logFile;
  21. }
  22. public function push() { return new PushPayload($this); }
  23. public function report() { return new ReportPayload($this); }
  24. public function device() { return new DevicePayload($this); }
  25. public function schedule() { return new SchedulePayload($this);}
  26. public function getAuthStr() { return $this->appKey . ":" . $this->masterSecret; }
  27. public function getRetryTimes() { return $this->retryTimes; }
  28. public function getLogFile() { return $this->logFile; }
  29. }