예제 #1
0
def get_users_list():
    """
    拉取关注用户列表
    :return:
    """
    token = get_access_token()
    url = 'https://api.weixin.qq.com/cgi-bin/user/get?access_token=' % token
    res = urlopen(url)
    json_content = json.loads(res.read())
    print json_content
예제 #2
0
def update_remark(openid, remark):
    api = SimpleApi.make_api(
        api_url="https://api.weixin.qq.com/cgi-bin/user/info/updateremark?access_token={token}".format(
            token=get_access_token()
        ),
        post_data={"openid": str(openid), "remark": str(remark)},
    )
    result = api.get_data()
    if result.get("errcode", 0) != 0:
        raise WeixinError(u"err in update_remark %s" % str(result))
    return True
예제 #3
0
 def get_next_openid_list(_next_openid):
     if _next_openid:
         api_url = "https://api.weixin.qq.com/cgi-bin/user/get?access_token={token}&next_openid={next_openid}".format(
             token=get_access_token(), next_openid=_next_openid
         )
     else:
         api_url = "https://api.weixin.qq.com/cgi-bin/user/get?access_token={token}".format(token=get_access_token())
     api = SimpleApi.make_api(api_url=api_url)
     # success result: {"total":2,"count":2,"data":{"openid":["","OPENID1","OPENID2"]},"next_openid":"NEXT_OPENID"}
     result = api.get_data()
     if "errorcode" in result:
         raise WeixinError(u"error when pull subscriber list return %s" % str(result))
     _next_openid = result.get("next_openid")
     # no more data
     if result.get("count") == 0:
         return [], None
     else:
         op_list = result["data"]["openid"]
         return op_list, _next_openid
예제 #4
0
    def __init__(self, action_name, scene_dict, expire_sec=None):
        if action_name not in [QrCodeTicket.QR_LIMIT_SCENE, QrCodeTicket.QR_SCENE]:
            raise AttributeError(), u"invalid action name"

        api_url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={token}".format(token=get_access_token())
        post_data = {
            "action_name": str(action_name),
            "action_info": {
                "scene": dict(scene_dict)
            }
        }
        if expire_sec:
            post_data["expire_seconds"] = int(expire_sec)

        self.post_data = post_data
        self.api_url = api_url
예제 #5
0
파일: js.py 프로젝트: zhongkunchen/tmweixin
 def __init__(self):
     super(JsApiTicket, self).__init__()
     token = get_access_token()
     self.api_url = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=%s&type=jsapi' % token