Rhymen / go-whatsapp

WhatsApp Web API
MIT License
2.04k stars 491 forks source link

cannot unmarshal array into Go value of type map[string]interface {} #644

Open hajsf opened 2 years ago

hajsf commented 2 years ago

Trying to implement the login example:

package main

import (
    "fmt"
    "os"
    "time"

    qrcodeTerminal "github.com/Baozisoftware/qrcode-terminal-go"
    "github.com/Rhymen/go-whatsapp"
)

func main() {
    wac, err := whatsapp.NewConn(5 * time.Second)
    if err != nil {
        panic(err)
    }

    qr := make(chan string)
    go func() {
        terminal := qrcodeTerminal.New()
        terminal.Get(<-qr).Print()
    }()

    session, err := wac.Login(qr)
    if err != nil {
        fmt.Fprintf(os.Stderr, "error during login: %v\n", err)
        return
    }
    fmt.Printf("login successful, session: %v\n", session)
}

But go the below error:

S C:\Users\senses\Documents\WhatsApp> go run whatsapp
error during login: error decoding login resp: json: cannot unmarshal array into Go value of type map[string]interface {}
zaytal commented 2 years ago

Try this solution https://github.com/Rhymen/go-whatsapp/issues/631

RafaelIngenium commented 2 years ago

the version I use is indicated at #631 and the problem continues (for new positions)