Nenhuma Descrição

custom_message.py 997B

12345678910111213141516171819202122232425262728293031323334
  1. # -*- coding: utf-8 -*-
  2. from django.conf import settings
  3. from pywe_custom_message import send_custom_wxa_message
  4. from pywe_media import media_upload
  5. from pywe_storage import RedisStorage
  6. from utils.redis.connect import r
  7. WECHAT = settings.WECHAT
  8. def mediaupload(media_file=None, media_file_path=None):
  9. wxcfg = WECHAT.get('JSAPI', {})
  10. appid = wxcfg.get('appID')
  11. secret = wxcfg.get('appsecret')
  12. res = media_upload(media_file=media_file, media_file_path=media_file_path, appid=appid, secret=secret, token=None, storage=RedisStorage(r))
  13. print(res)
  14. def sendcustomwxamessage(openid=None, miniappid=None, pagepath=None, thumb_media_id=None, title=None):
  15. wxcfg = WECHAT.get('JSAPI', {})
  16. appid = wxcfg.get('appID')
  17. secret = wxcfg.get('appsecret')
  18. res = send_custom_wxa_message(openid=openid, miniappid=miniappid, pagepath=pagepath, thumb_media_id=thumb_media_id, title=title, appid=appid, secret=secret, token=None, storage=RedisStorage(r))
  19. print(res)