When I try sent message, It sent to my number.
How to set it to my other friend number?
Asamsulfat, Whatsapp uses a JID system for user identification. Look at this code fragment from the README.md.
text := whatsapp.TextMessage{
Info: whatsapp.MessageInfo{
RemoteJid: "[email protected]",
},
Text: "Hello Whatsapp",
}
err := wac.Send(text)
Please take note of the RemoteJid line. If you want to sent a message to somebody else, put their Jid here, or if you want to send a message to a group put its Jid there.
A persons Jid is structured like this: [phonenumber without + or 00]@s.whatsapp.net.
A group: [phonenumber of creator without + or 00]-[time of creation in UNIX]@g.us
Hope it helps,
Walthzer
my friend number
0813 2708 5596
my country number +62 (Indonesia)
So I remove 0 and +62
and
RemoteJid: "[email protected]"
but it was sent to my own number, not my friend number.
No, keep the country code, but remove the + in front of the code. > [email protected];
Wow this is awesome, thank you very much.
Is there anyway to read our all whatsapp contacts and can retrieve respective ReoteJIDs and can send message one by one.
You can retrieve you whatsapp contacts by calling
wac.Contacts()
Then the contact list in wac.Store.Contacts gets updated or you can make use of an handler to handle the list of contacts after calling the function above
func (handler Handler) HandleContactList(contacts []whatsapp.Contact) {
fmt.Print(contacts)
}
Thanks @Deewai , is there any way to get Profile Pic URL from the contact list?
@sandeepmeenuga use wac.GetProfilePicThumb(RemoteJid)
type ThumbUrl struct {
EURL string `json:"eurl"`
Tag string `json:"tag"`
Status int64 `json:"status"`
}
profilePicThumb, _ := wac.GetProfilePicThumb(RemoteJid)
profilePic := <-profilePicThumb
thumbnail := ThumbUrl{}
json.Unmarshal([]byte(profilePic), &thumbnail)
fmt.Println(thumbnail.EURL)
Thanks @codenoid, I am pretty new for this API. could you share any doc link or anything. So, I can go through once and start using.
No, keep the country code, but remove the + in front of the code. > [email protected];
This should be in the readme ;)
Most helpful comment
No, keep the country code, but remove the + in front of the code. > [email protected];