From 1ed40485c0b6bcc0f32f3d488f64088662b3fb18 Mon Sep 17 00:00:00 2001 From: themester Date: Sun, 1 Jul 2018 20:52:45 +0200 Subject: [PATCH 1/3] Fixed https://github.com/ahmdrz/goinsta/issues/142 --- goinsta.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/goinsta.go b/goinsta.go index e1142b4a..f70d790c 100644 --- a/goinsta.go +++ b/goinsta.go @@ -332,7 +332,7 @@ func (inst *Instagram) Login() error { if err != nil { return err } - _, err = inst.sendRequest( + body, err := inst.sendRequest( &reqOptions{ Endpoint: urlLogin, Query: generateSignature(b2s(result)), @@ -347,6 +347,10 @@ func (inst *Instagram) Login() error { // getting account data res := accountResp{} + err = json.Unmarshal(body, &res) + if err != nil { + return err + } inst.Account = &res.Account inst.Account.inst = inst From d75fb377bd1504784c620e2e185a2ec1b2550bab Mon Sep 17 00:00:00 2001 From: themester Date: Sun, 1 Jul 2018 21:10:39 +0200 Subject: [PATCH 2/3] Made Account.Sync user id independent --- account.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/account.go b/account.go index a9a147e3..ab1db9ad 100644 --- a/account.go +++ b/account.go @@ -73,7 +73,15 @@ type Account struct { // Sync updates account information func (account *Account) Sync() error { insta := account.inst - body, err := insta.sendSimpleRequest(urlUserByID, account.ID) + data, err := insta.prepareData() + if err != nil { + return err + } + body, err := insta.sendRequest(&reqOptions{ + Endpoint: urlCurrentUser, + Query: generateSignature(data), + IsPost: true, + }) if err == nil { resp := profResp{} err = json.Unmarshal(body, &resp) From 95cdc4ae8ca6f5242d0dada05a0b3992e4a9555d Mon Sep 17 00:00:00 2001 From: themester Date: Sun, 1 Jul 2018 21:10:57 +0200 Subject: [PATCH 3/3] Fixed Save() error --- goinsta.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/goinsta.go b/goinsta.go index f70d790c..64fefe71 100644 --- a/goinsta.go +++ b/goinsta.go @@ -129,12 +129,12 @@ func (inst *Instagram) UnsetProxy() { } // Save exports config to ~/.goinsta -func (inst *Instagram) Save() { - home := os.Getenv("$HOME") +func (inst *Instagram) Save() error { + home := os.Getenv("HOME") if home == "" { - home = os.Getenv("$home") // for plan9 + home = os.Getenv("home") // for plan9 } - inst.Export(filepath.Join(home, ".goinsta")) + return inst.Export(filepath.Join(home, ".goinsta")) } // Export exports *Instagram object options