Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何设置公众号刚被关注时给用户发的消息的内容? #31

Open
weixiao-huang opened this issue Aug 3, 2017 · 9 comments

Comments

@weixiao-huang
Copy link

RT,找了半天文档,似乎没有找着,求助

@SJK132
Copy link

SJK132 commented Aug 3, 2017

来我教你

@itchatmp.msg_register(itchatmp.content.EVENT)
def user_management(event):
    if(event['Event']=='subscribe'):
        return u'你就这样给用户发信息就好了'

@weixiao-huang
Copy link
Author

@SJK132 非常感谢,可行了!还有个问题想请教一下,如果我是个人号(没有认证),那是不是itchatmp.send('hello', fromUser)这个接口在被动回复的情况下是没作用的?如下:

@itchatmp.msg_register([TEXT])
def reply_img(msg):
    toUserName = msg['FromUserName']
    print(toUserName)
    itchatmp.send('hello', toUserName)

如果不行的话,只用return返回消息的方式,可以在被动回复中发图片、视频之类的消息吗?
谢谢!

@SJK132
Copy link

SJK132 commented Aug 3, 2017

如果用户主动找你了 你应该可以用send() 再24/48hr内 (我不记得是哪个了)

@weixiao-huang
Copy link
Author

@SJK132 对我的意思就是用户主动找我了,用户给我发消息了。然而我发现这里调用itchatmp.send('hello', toUserName)并没有成功给用户发送消息,console里也没有提示错误。只有用return的话才能发文本消息给用户

@SJK132
Copy link

SJK132 commented Aug 3, 2017

试试这个

r = itchatmp.send('hello',tousername)
print(r)

@weixiao-huang
Copy link
Author

@SJK132 谢谢!看到错误了,api功能未授权,请确认公众号已获得该接口,可以在公众平台官网-开发者中心页中查看接口权限,可能是公众号需要认证开通权限的关系。

@SJK132
Copy link

SJK132 commented Aug 3, 2017

还有我也在研究如何return个图片回去 是可以做到的 微信里有这接口

@weixiao-huang
Copy link
Author

@SJK132 我现在尝试了一下,如果是本地的图片,直接return '@[email protected]'可以实现把当前目录下图片发给用户,图片大小应该是5M以内

@SJK132
Copy link

SJK132 commented Aug 3, 2017

谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants