Skip to content

Commit 4eb2917

Browse files
committed
merge and update Import and Export
2 parents 3a217dd + 8a4b107 commit 4eb2917

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

account.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,15 @@ type Account struct {
7373
// Sync updates account information
7474
func (account *Account) Sync() error {
7575
insta := account.inst
76-
body, err := insta.sendSimpleRequest(urlUserByID, account.ID)
76+
data, err := insta.prepareData()
77+
if err != nil {
78+
return err
79+
}
80+
body, err := insta.sendRequest(&reqOptions{
81+
Endpoint: urlCurrentUser,
82+
Query: generateSignature(data),
83+
IsPost: true,
84+
})
7785
if err == nil {
7886
resp := profResp{}
7987
err = json.Unmarshal(body, &resp)

goinsta.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ func (inst *Instagram) UnsetProxy() {
130130
}
131131

132132
// Save exports config to ~/.goinsta
133-
func (inst *Instagram) Save() {
134-
home := os.Getenv("$HOME")
133+
func (inst *Instagram) Save() error {
134+
home := os.Getenv("HOME")
135135
if home == "" {
136-
home = os.Getenv("$home") // for plan9
136+
home = os.Getenv("home") // for plan9
137137
}
138-
inst.Export(filepath.Join(home, ".goinsta"))
138+
return inst.Export(filepath.Join(home, ".goinsta"))
139139
}
140140

141141
// Export exports *Instagram object options
@@ -369,7 +369,7 @@ func (inst *Instagram) Login() error {
369369
if err != nil {
370370
return err
371371
}
372-
_, err = inst.sendRequest(
372+
body, err := inst.sendRequest(
373373
&reqOptions{
374374
Endpoint: urlLogin,
375375
Query: generateSignature(b2s(result)),
@@ -384,6 +384,10 @@ func (inst *Instagram) Login() error {
384384

385385
// getting account data
386386
res := accountResp{}
387+
err = json.Unmarshal(body, &res)
388+
if err != nil {
389+
return err
390+
}
387391

388392
inst.Account = &res.Account
389393
inst.Account.inst = inst

users.go

+5
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ func (users *Users) Next() bool {
8080
return false
8181
}
8282

83+
// Error returns users error
84+
func (users *Users) Error() error {
85+
return users.err
86+
}
87+
8388
func (users *Users) setValues() {
8489
for i := range users.Users {
8590
users.Users[i].inst = users.inst

0 commit comments

Comments
 (0)