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

Commit

Permalink
Merge branch 'alpha' of ssh://github.com:/ahmdrz/goinsta into alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrr committed Jul 3, 2018
2 parents 0290b5e + 95cdc4a commit 8a4b107
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
10 changes: 9 additions & 1 deletion account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 9 additions & 5 deletions goinsta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)),
Expand All @@ -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
Expand Down

0 comments on commit 8a4b107

Please sign in to comment.