|
@@ -117,13 +117,13 @@ class WechatMPClient: |
|
|
"type": media_type |
|
|
"type": media_type |
|
|
} |
|
|
} |
|
|
files={"media": media_file} |
|
|
files={"media": media_file} |
|
|
logger.info("[wechatmp] media {} uploaded".format(media_file)) |
|
|
|
|
|
ret = self.wechatmp_request( |
|
|
ret = self.wechatmp_request( |
|
|
method="post", |
|
|
method="post", |
|
|
url=url, |
|
|
url=url, |
|
|
params=params, |
|
|
params=params, |
|
|
files=files |
|
|
files=files |
|
|
) |
|
|
) |
|
|
|
|
|
logger.debug("[wechatmp] media {} uploaded".format(media_file)) |
|
|
return ret["media_id"] |
|
|
return ret["media_id"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -134,13 +134,13 @@ class WechatMPClient: |
|
|
"type": media_type |
|
|
"type": media_type |
|
|
} |
|
|
} |
|
|
files={"media": media_file} |
|
|
files={"media": media_file} |
|
|
logger.info("[wechatmp] media {} uploaded".format(media_file)) |
|
|
|
|
|
ret = self.wechatmp_request( |
|
|
ret = self.wechatmp_request( |
|
|
method="post", |
|
|
method="post", |
|
|
url=url, |
|
|
url=url, |
|
|
params=params, |
|
|
params=params, |
|
|
files=files |
|
|
files=files |
|
|
) |
|
|
) |
|
|
|
|
|
logger.debug("[wechatmp] permanent media {} uploaded".format(media_file)) |
|
|
return ret["media_id"] |
|
|
return ret["media_id"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -149,13 +149,13 @@ class WechatMPClient: |
|
|
params={ |
|
|
params={ |
|
|
"access_token": self.get_access_token() |
|
|
"access_token": self.get_access_token() |
|
|
} |
|
|
} |
|
|
logger.info("[wechatmp] media {} deleted".format(media_id)) |
|
|
|
|
|
self.wechatmp_request( |
|
|
self.wechatmp_request( |
|
|
method="post", |
|
|
method="post", |
|
|
url=url, |
|
|
url=url, |
|
|
params=params, |
|
|
params=params, |
|
|
data={"media_id": media_id} |
|
|
|
|
|
|
|
|
data=json.dumps({"media_id": media_id}, ensure_ascii=False).encode("utf8") |
|
|
) |
|
|
) |
|
|
|
|
|
logger.debug("[wechatmp] permanent media {} deleted".format(media_id)) |
|
|
|
|
|
|
|
|
def clear_quota(self): |
|
|
def clear_quota(self): |
|
|
url="https://api.weixin.qq.com/cgi-bin/clear_quota" |
|
|
url="https://api.weixin.qq.com/cgi-bin/clear_quota" |
|
@@ -168,6 +168,7 @@ class WechatMPClient: |
|
|
params=params, |
|
|
params=params, |
|
|
data={"appid": self.app_id} |
|
|
data={"appid": self.app_id} |
|
|
) |
|
|
) |
|
|
|
|
|
logger.debug("[wechatmp] API quata has been cleard") |
|
|
|
|
|
|
|
|
def clear_quota_v2(self): |
|
|
def clear_quota_v2(self): |
|
|
url="https://api.weixin.qq.com/cgi-bin/clear_quota/v2" |
|
|
url="https://api.weixin.qq.com/cgi-bin/clear_quota/v2" |
|
@@ -176,3 +177,4 @@ class WechatMPClient: |
|
|
url=url, |
|
|
url=url, |
|
|
data={"appid": self.app_id, "appsecret": self.app_secret} |
|
|
data={"appid": self.app_id, "appsecret": self.app_secret} |
|
|
) |
|
|
) |
|
|
|
|
|
logger.debug("[wechatmp] API quata has been cleard") |