初玩whatsapp 的命令行小伙伴

whatsapp 的命令行小伙伴

环境:仅限在中国大陆地区联通手机用户
网络:无需翻墙

update:

whatapp会封第三方的接口,这方面的问题没有法子,希望网友自行解决。

本文提供思路,而且是2016年的尝试,仅供参考


1 注册

请求注册

`
yowsup-cli registration –requestcode sms –phone 86xxx######## –cc 86 –mcc 460 –mnc 01

`

INFO:yowsup.common.http.warequest:{"status":"sent","length":6,"method":"sms","retry_after":65,"sms_wait":65,"voice_wait":65}

status: sent
retry_after: 65
length: 6
method: sms

使用注册码,get密码

yowsup-cli registration --register ***-*** --phone 86xxx######## --cc 86

status: ok
kind: free
pw: &&&
price: ¥6.00
price_expiration: 1471558176
currency: CNY
cost: 6.00
expiration: 4444444444.0
login: 86xxx########
type: existing

2 使用

预先配置账号config
## Actual config starts below ##    
 cc=86 #if not specified it will be autodetected
 phone=86xxxxxxxxxx
 password=xxxxxxxxxxxxxxx=
demo登陆


yowsup-cli demos --yowsup --config config

勤用/help

列举常用命令

/L                                                          Quick login         
/message       broadcast      <numbers> <content>           Broadcast message. numbers should comma separated phone numbers
/message       send           <number> <content>            Send message to a friend
/image         send           <number> <path> [caption]     Send an image with optional caption
/groups        create         <subject> [jids]              Create a new group with the specified subject and participants. Jids are a comma separated list but optional.
/audio         send           <number> <path>               Send audio file     
正式登陆

输入/L姐可以登陆

发消息


/message send 86xxxxxxxxxx "This is a message sent from 甲苯狗"

收消息

当然就是等待

Alt text

结果在这里

3 小结

文本双向通信OK
多媒体有option支持,但我的环境尝试不稳定

4 其他

issue send wav to phone
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/protocol_media/protocolentities/message_media_downloadable_audio.py", line 96, in fromFilePath
    entity = DownloadableMediaMessageProtocolEntity.fromFilePath(fpath, url, DownloadableMediaMessageProtocolEntity.MEDIA_TYPE_AUDIO, ip, to, mimeType, preview)
AttributeError: type object 'DownloadableMediaMessageProtocolEntity' has no attribute 'fromFilePath'

ERROR:yowsup.demos.cli.layer:Upload file /home/noya/Desktop/ambeHome/english_sample/espeak/wav8k/numbers/six.wav to https://mmi678.whatsapp.net/u/OC3hgm1TvTJnC6q9nfk8RreZuOUABTfM-jyi9A/Ak1pLOyURps9-V9sL7D6xZRkkpB3za1UXDml37fcDK-- for 86#########@s.whatsapp.net failed!
bug time when receive UTF-8 words
    MESSAGE_ID = message.getId()
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)

bug time when get audio
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/axolotl/layer_receive.py", line 88, in handleEncMessage
    self.handleWhisperMessage(node)
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/axolotl/layer_receive.py", line 144, in handleWhisperMessage
    self.parseAndHandleMessageProto(encMessageProtocolEntity, plaintext[:-padding])
  File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/axolotl/layer_receive.py", line 204, in parseAndHandleMessageProto
    raise ValueError("Unhandled")
ValueError: Unhandled

bug 多媒体当前bug状态

Alt text

issue 重发message情形

Alt text

to try 一条命令发送text


python yowsup-cli demos -c /root/.yowsup/config -s 441234567890 "Hola"
python yowsup-cli demos -c /root/.yowsup/config -s 441234567890 "Hola" -n "Happy birthday"

more for this tip

参考


official guide : yowsup-cli

guide :WhatsApp on Raspberry Pi

whatsapp 年费政策介绍
whatsapp 免费介绍

工业支持情况

intel 论坛态度 支持whatsapp

多媒体支持

多媒体在yowsup上面的支持情况

offical : Upload and send Media
2014年支持 多媒体的方案

### 使用 WhatsApp API 进行应用开发 #### 准备工作 为了成功利用WhatsApp API进行应用开发,开发者需先理解所选API的具体特性及其适用场景。对于企业级解决方案而言,通常会选择使用WhatsApp Business API或WhatsApp Cloud API[^2]。 #### 开发环境搭建 确保拥有稳定的网络环境至关重要,因为这直接影响到API请求的成功率和响应时间。建议参考官方文档来配置必要的代理服务或其他中间件以优化网络性能[^1]。 #### 应用程序创建 无论是选择哪种类型的API接口,在正式接入前都需要完成一系列初始化设置: - 注册成为开发者并获取相应权限; - 创建项目并通过认证流程获得访问令牌; - 配置Webhook用于接收来自WhatsApp的消息通知; ```json { "webhooks": { "url": "https://yourdomain.com/webhook", "verify_token": "YOUR_VERIFY_TOKEN" } } ``` #### 发送消息示例 下面是一个简单的Python脚本例子,展示了如何向指定联系人发送文本消息: ```python import requests def send_message(phone_number, message_text): url = 'https://graph.facebook.com/v13.0/WHATSAPP_API_PHONE_NUMBER_ID/messages' headers = {'Authorization': f'Bearer YOUR_ACCESS_TOKEN'} payload = { "messaging_product": "whatsapp", "recipient_type": "individual", "to": phone_number, "type": "text", "text": {"body": message_text} } response = requests.post(url=url, json=payload, headers=headers) if __name__ == '__main__': send_message('123456789', 'Hello from your app!') ``` 此代码片段假设读者已经获得了有效的`ACCESS_TOKEN`以及正确的`PHONE_NUMBER_ID`参数值,并将其替换为实际使用的凭证信息。 #### 数据安全与隐私保护 在整个过程中始终重视数据的安全性和用户的隐私权。遵循GDPR等相关法律法规的要求,妥善保管用户个人信息,避免泄露风险。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值