def getTemplateID(self, MID): url = self._getTemplateIdUrl if int(MID) < 10: MID = "0" + MID data = """{ "template_id_short": "TM000%s", }""" % (MID) return JsonRespone(url, data)
def getMediaIdList(self, type, offset, count): url = self._listUrl data = """{ "type": "%s", "offset": %d, "count" : %d }""" % (type, offset, count) return JsonRespone(url, data)
def sendTemplateMessage(self, openID, templateID, templateUrl, data): url = self._sendTemplateMessageUrl data = """ { "touser":"******", "template_id":"%s", "url":"%s", "data":%s }""" % (openID, templateID, templateUrl, data) return JsonRespone(url, data)
def sendTextMessage(self,openID,context): url = self._messageUrl data = """{ "touser": "******", "msgtype": "text", "text": { "content": "%s" } }"""%(openID,context) return JsonRespone(url,data)
def sendImageMessage(self,openID,mediaID): url = self._messageUrl data = """{ "touser": "******", "msgtype": "image", "image": { "media_id": "%s" } }"""%(openID,mediaID) return JsonRespone(url,data)
def sendSingleArticlesMessage(self,openID,articles): url = self._messageUrl data = """{ "touser":"******", "msgtype":"news", "news":{ "articles": [ { "title":"%s", "description":"%s", "url":"%s", "picurl":"%s" } ] } }"""%(openID, articles['title'], articles['description'], articles['url'], articles['picurl'], ) return JsonRespone(url,data)
def getTemplateList(self, templateID): url = self._getTemplateListUrl data = "" return JsonRespone(url, data)
def _get_access_token(self): url = self._get_access_token_url data = "" return JsonRespone(url, data)['access_token']