File tree 3 files changed +23
-6
lines changed
3 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,15 @@ type Account struct {
73
73
// Sync updates account information
74
74
func (account * Account ) Sync () error {
75
75
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
+ })
77
85
if err == nil {
78
86
resp := profResp {}
79
87
err = json .Unmarshal (body , & resp )
Original file line number Diff line number Diff line change @@ -130,12 +130,12 @@ func (inst *Instagram) UnsetProxy() {
130
130
}
131
131
132
132
// 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" )
135
135
if home == "" {
136
- home = os .Getenv ("$ home" ) // for plan9
136
+ home = os .Getenv ("home" ) // for plan9
137
137
}
138
- inst .Export (filepath .Join (home , ".goinsta" ))
138
+ return inst .Export (filepath .Join (home , ".goinsta" ))
139
139
}
140
140
141
141
// Export exports *Instagram object options
@@ -369,7 +369,7 @@ func (inst *Instagram) Login() error {
369
369
if err != nil {
370
370
return err
371
371
}
372
- _ , err = inst .sendRequest (
372
+ body , err : = inst .sendRequest (
373
373
& reqOptions {
374
374
Endpoint : urlLogin ,
375
375
Query : generateSignature (b2s (result )),
@@ -384,6 +384,10 @@ func (inst *Instagram) Login() error {
384
384
385
385
// getting account data
386
386
res := accountResp {}
387
+ err = json .Unmarshal (body , & res )
388
+ if err != nil {
389
+ return err
390
+ }
387
391
388
392
inst .Account = & res .Account
389
393
inst .Account .inst = inst
Original file line number Diff line number Diff line change @@ -80,6 +80,11 @@ func (users *Users) Next() bool {
80
80
return false
81
81
}
82
82
83
+ // Error returns users error
84
+ func (users * Users ) Error () error {
85
+ return users .err
86
+ }
87
+
83
88
func (users * Users ) setValues () {
84
89
for i := range users .Users {
85
90
users .Users [i ].inst = users .inst
You can’t perform that action at this time.
0 commit comments