找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 1802|回复: 0

[求助] itchat中的加好友功能是不是不能用了

1

主题

4

帖子

4

积分

贫民

积分
4
TerryDe_v4XOH 发表于 2020-1-8 11:45:43 | 显示全部楼层 |阅读模式
这两天在学习itchat, 已经可以看到群成员的列表信息了, 我试了下加个好友; 但是好像没啥响应; 又去招同事试了下,确实没反应;
程序响应

代码:

res=itchat.add_friend(userName='@15d76',status=2,autoUpdate=True,verifyContent='hello from terry')
print(type(res),'\n', res)



响应
<class 'itchat.returnvalues.ReturnValue'>
{'BaseResp**e': {'Ret': 1, 'ErrMsg': '', 'RawMsg': ''}}


库函数的定义
def add_friend(self, userName, status=2, verifyContent='', autoUpdate=True):
    ''' Add a friend or accept a friend
        * for adding status should be 2
        * for accepting status should be 3
    '''
    url = '%s/webwxverifyuser?r=%s&pass_ticket=%s' % (
        self.loginInfo['url'], int(time.time()), self.loginInfo['pass_ticket'])
    data = {
        'BaseRequest': self.loginInfo['BaseRequest'],
        'Opcode': status, # 3
        'VerifyUserListSize': 1,
        'VerifyUserList': [{
            'Value': userName,
            'VerifyUserTicket': '', }],
        'VerifyContent': verifyContent,
        'SceneListCount': 1,
        'SceneList': [33],
        'skey': self.loginInfo['skey'], }
    headers = {
        'ContentType': 'application/json; charset=UTF-8',
        'User-Agent' : config.USER_AGENT }
    r = self.s.post(url, headers=headers,
        data=json.dumps(data, ensure_ascii=False).encode('utf8', 'replace'))
    if autoUpdate:
        self.update_friend(userName)
    return ReturnValue(rawResp**e=r)


求指教
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表