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.

44 lines
996 B

  1. <?php
  2. namespace App\Common;
  3. /**
  4. * OAuth2.0微信授权登录实现
  5. *
  6. * @author FLi
  7. * @文件名:GetWxUserInfo.php
  8. */
  9. class WechatAuth
  10. {
  11. //高级功能->开发者模式->获取
  12. private $app_id = 'xxx';
  13. private $app_secret = 'xxxxxxx';
  14. //$registration_id = getenv('registration_id');
  15. public static function send($msg, $param='')
  16. {
  17. $client = new JPushMsg(self::APP_KEY, self::APP_SECRET, null);
  18. $push_payload = $client->push();
  19. $push_payload = $push_payload->setPlatform('all');
  20. if(isset($param['mobile'])){$push_payload = $push_payload->addAlias(md5($param['mobile']));}
  21. $push_payload = $push_payload->addAllAudience();
  22. $push_payload = $push_payload->setNotificationAlert($msg);
  23. try
  24. {
  25. $push_payload->send();
  26. }
  27. catch (JPushMsg\Exceptions\APIConnectionException $e)
  28. {
  29. Log::info($e);
  30. return false;
  31. }
  32. catch (JPushMsg\Exceptions\APIRequestException $e)
  33. {
  34. Log::info($e);
  35. return false;
  36. }
  37. return true;
  38. }
  39. }