Skip to content
This repository has been archived by the owner on Aug 25, 2023. It is now read-only.

Error while calling DirectMessage two times #111

Closed
alejoloaiza opened this issue May 10, 2018 · 5 comments
Closed

Error while calling DirectMessage two times #111

alejoloaiza opened this issue May 10, 2018 · 5 comments

Comments

@alejoloaiza
Copy link
Contributor

alejoloaiza commented May 10, 2018

Hello, I'm facing error while using DirectMessage two times for same user, even with a sleep of 5 seconds in between, first message reaches the other user, but second message does NOT reach. It is important to mention that there is not error returned for neither of the calls, both return status ok, but the second message is lost (lost in the sense that is not visible in the instagram app). This is the code:

func main() {
	insta := goinsta.New("myuser", "mypwd")
	if err := insta.Login(); err != nil {
		panic(err)
	}
	defer insta.Logout()
	user, err := insta.GetUserByUsername("the user name of someone your follow")
	var Id int64
	Id = user.User.ID
	fmt.Println(Id)
	_, err = insta.DirectMessage(strconv.FormatInt(Id, 10), "Hello 1")
	if err != nil {
		fmt.Println(err)
	}
	time.Sleep(5 * time.Second)
	resp, err := insta.DirectMessage(strconv.FormatInt(Id, 10), "Hello 2")
	if err != nil {
		fmt.Println(err)
	}
	b, err := json.Marshal(resp)
	fmt.Println(string(b))
}
@dgrr
Copy link
Contributor

dgrr commented May 10, 2018

Okay. Thank you for your report. I am going to test it.

@dgrr
Copy link
Contributor

dgrr commented May 11, 2018

@alejoloaiza I think is instagram problem. Right now I am searching the root problem. I will contact you when I discover anything.

@alejoloaiza
Copy link
Contributor Author

Thanks @TheMester , I tried send message 1, logout, create insta variable again login and send message 2 and it worked, i think is something related to session or context, dont know exactly what.

func main() {
	insta := goinsta.New("myuser", "mypwd")
	if err := insta.Login(); err != nil {
		panic(err)
	}
	defer insta.Logout()
	user, err := insta.GetUserByUsername("the user name of someone you follow")
	var Id int64
	Id = user.User.ID
	fmt.Println(Id)
	_, err = insta.DirectMessage(strconv.FormatInt(Id, 10), "Hello 1")
	if err != nil {
		fmt.Println(err)
	}
	insta.Logout()
	time.Sleep(15 * time.Second)
	insta = goinsta.New("myuser", "mypwd")
	if err := insta.Login(); err != nil {
		panic(err)
	}
	resp, err := insta.DirectMessage(strconv.FormatInt(Id, 10), "Hello 2")
	if err != nil {
		fmt.Println(err)
	}
	b, err := json.Marshal(resp)
	fmt.Println(string(b))
}

@dgrr
Copy link
Contributor

dgrr commented May 11, 2018

I think it's problem of thread_ids post parameter. I am going to apply a patch in a few hours. Even so do not be impatient, I think the new release (alpha branch) will be ready the next week (probably after this weekend)

@alejoloaiza
Copy link
Contributor Author

Ok man no problem, Will wait for the alpha branch, Thanks a lot @TheMester .

@dgrr dgrr closed this as completed May 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants