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

Commit cf89031

Browse files
authored
Sync with master branch. (#219)
* implement UserTaggedFeed for media a used is tagged in * add test for maxid/mintimestamp for UserTaggedFeed * new response type for usertaggedfeed (#98) * change UserTaggedFeed return to new type with int64 next_max_id and extra fields * change test case * change int -> int64 for next_max_id * update GetUserStories * add story to location feeds * Update README.md * Added comments to DirectMessage function * Updated DirectListResponse * Adapted cursor requests in GetV2Inbox * Changed doc.go file * Fixed errors * Changed doc.go * Changed examples import * Changed goinsta imports * updatd readme * Updated doc.go * Updated utils * Added Comment.Like and Unlike * Changed requests * Added Commends.Add support for Stories (incomplete) * Fixed error with GET request * Deleted limit parameter * Resumed code * Added pagination for Inbox object * Added next example * Updated readme * fixed typo * Updated README * Updated README 2 * Added CookieJar in New function * Fixed hashtag user error * Fixed #117 * Changed user-agent * Added Send function to Converstions * Added new field for requests * Added send message example * Added documentation example * Returned to last user agent. WHY is 44 version older than 10? * Added new error type and finished Comments.Add to StoryMedia * Updated example * Added Delete function * Added Like function * Added example * Added new urls * Added V2 parameter to request function * add SyncLikers function to get media likers * update * add urlMediaLikers in const and used in SyncLikers * Added mutual friends field * Updated user agent * Added highligh function * Added highligh example * Added highlights command to user * Made SyncLikers a little private heh * Restored user-agent * Added Sync function for highlights * Add go.mod for use with VGO * Fixed error with highlights * add UploadPhoto * Added NewUser function * Added field title to story media * Added documentation * Changed Download function * Deleted fmt and change for Join paths xd * Changed Download function * Updated info command * Updated Download functions * Updated * Changed readme and doc.go * Updated readme * Updated readme * Added GetBest * Changed Download function flow execution * Updated setToItem function * Fixed CarouselMedia error * Changed AcquireFeed to GetMedia * Updated exaples * Changed Feed parameters * Modified Sync input parameters * Created friendship example * Updated doc * Updated godoc info * Updated Account.Feed * Fixed comment const error * Added Item processing to GetBest * Fixed comment retrieving error * Fixed error * F********************CK * Fixed comments pagination error * New login on testing mode * Little patch to solve #123 * Updated sync example * Updated Sync account function * Deleted unneeded const * Added insecure mode to proxy * Implemented new login * Changed close default value by keep-alive * Deleted second user agent * Fixed #120 * Fixed highlights error * Updated readme * Create CONTRIBUTING.md * Deleted CONTRIBUTION * Create LICENSE * Updated readme * Updated readme * [Add] Other examples * Added edit function in account update functions * Added urls * Changed example args * Limited item listing * Fixed edit error * Added Save function * Fixed _uid paramter error * Added more information to error * [Add] Optional argument to modify query options * This reverts commit b4cd0fb. * [Add] Open posibility to change to non ranked content * [Add] Bool in switch and comment * [Update] Comment typo error * [Add] New method to have a way to initiate a new conversation * [Update] Requested changes * [Update] fix misspell <- found by goreportcard report * [Update] fix ineffassign <- found by goreportcard report * [Update] Run gofmt -s <- This was found on goreportcard.com * Fixed test errors * [Update] golint fixes reported by goreportcard.com (#135) * [Update] set 1 of golint fixes reported by goreportcard.com * [Update] set 2 of golint fixes reported by goreportcard.com * [Update] set 3 of golint fixes reported by goreportcard.com * [Update] Adjusted using early return best practice and also to fix the last issues on ineffassign by goreportcard * Fixed go_vet errors * [Update] Fix remaining golint issues reported, should be 100% after this * Added new error reporting types * Fixed #142 * Made Account.Sync user id independent * Fixed Save() error * Added Error function to users * update Import and Export functions * Use int64 type for long integers where neccessary (#1) Closes #149 * Fix unmarshal error on Nametag.SelfieSticker Fixes #156 * Unmarshall was replaced with json decoder to eliminate the problems of float64 with big numbers * SelfieSticker from string to interface{} avoiding json error * Remove duplicated functions The content of account_test.go can be found in examples/account/ Fixes #155 * Add v2 suffix in go.mod module * add Feed member. new function for locationID search added * feedTag moved to Feed * [Add Example] See who doesn't follow back * Unfollow everyone * add SetController for User struct * rename SetController to SetInstagram * Update types.go fix Nametag problem (#177) * Fix file name for downloading (#182) * update Gradient in Nametag * Update README.md (#185) * Constacts synchronization added (#184) Ability to search users by emails and mobile phones * Media sync (#197) * Fix: error 405 for media.sync when request with POST * Media: create setter for instagram * fix #199 & #201 type mismatch (#200) * Update newconversation.go * Update types.go * using json number (#202) * update README * Update CONTRIBUTING.md * Fixed type of LastSeenAt in Conversion struct * Added iterating over pending inbox messages * Updated go.mod path to /v2 (#203) * Fix comments pagination * Fix wrong datatype (#208) * Fix interface{} unmarshalling * Improves hashtags isolation/recognition * minor changes * Update README.md * Update inbox.go Fixes #213 * Remove not used import
1 parent 73746e1 commit cf89031

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+2551
-934
lines changed

CONTRIBUTING.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Contribution
2+
3+
Welcome programmer!
4+
5+
If you want to contribute to Goinsta API you must follow a simple instructions.
6+
7+
- **Test your code after making pull request**. The title says it all.
8+
- **Include jokes if you can**. This instruction is optional.

CONTRIBUTION.md

-11
This file was deleted.

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Ahmadreza Zibaei
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+55-59
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,99 @@
1-
# GoInsta. Make Goinsta Great Again!
2-
<p align="center"><img width=100% src="https://raw.github.com/ahmdrz/goinsta/master/resources/goinsta-image.png"></p>
1+
### Go + Instgaram API
2+
<p align="center"><img width=100% src="https://raw.githubusercontent.com/ahmdrz/goinsta/v1/resources/goinsta-image.png"></p>
33

44
> Unofficial Instagram API for Golang
55
6-
[![Build Status](https://travis-ci.org/ahmdrz/goinsta.svg?branch=master)](https://travis-ci.org/ahmdrz/goinsta) [![GoDoc](https://godoc.org/github.com/ahmdrz/goinsta?status.svg)](https://godoc.org/github.com/ahmdrz/goinsta) [![Go Report Card](https://goreportcard.com/badge/github.com/ahmdrz/goinsta)](https://goreportcard.com/report/github.com/ahmdrz/goinsta) [![Coverage Status](https://coveralls.io/repos/github/ahmdrz/goinsta/badge.svg?branch=master)](https://coveralls.io/github/ahmdrz/goinsta?branch=master)
6+
[![GoDoc](https://godoc.org/github.com/ahmdrz/goinsta?status.svg)](https://godoc.org/github.com/ahmdrz/goinsta) [![Go Report Card](https://goreportcard.com/badge/github.com/ahmdrz/goinsta)](https://goreportcard.com/report/github.com/ahmdrz/goinsta)
77

8-
## Features
8+
### Features
99

1010
* **HTTP2 by default. Goinsta uses HTTP2 client enhancing performance.**
1111
* **Object independency. Can handle multiple instagram accounts.**
1212
* **Like Instagram mobile application**. Goinsta is very similar to Instagram official application.
1313
* **Simple**. Goinsta is made by lazy programmers!
1414
* **Backup methods**. You can use `Export` and `Import` functions.
1515
* **Security**. Your password is only required to login. After login your password is deleted.
16-
* **No External Dependencies**. Goinsta will not use any Go packages outside of the standard library.
16+
* **No External Dependencies**. GoInsta will not use any Go packages outside of the standard library.
1717

18-
## New Version !
19-
20-
We are working on `alpha` branch. Try it and tell us your suggestions!
21-
22-
The newer versions will be exported into v2 branch when new features will be well tested.
23-
24-
## Package installation
18+
### Package installation
2519

2620
`go get -u -v gopkg.in/ahmdrz/goinsta.v2`
2721

28-
## CLI installation
22+
### CLI installation
2923

3024
```
3125
go get -u -v gopkg.in/ahmdrz/goinsta.v2
3226
go install gopkg.in/ahmdrz/goinsta.v2/goinsta
3327
```
3428

35-
## Example
29+
### Example
3630

3731
```go
3832
package main
3933

4034
import (
4135
"fmt"
4236

43-
"github.com/ahmdrz/goinsta"
37+
"gopkg.in/ahmdrz/goinsta.v2"
4438
)
4539

4640
func main() {
47-
insta := goinsta.New("USERNAME", "PASSWORD")
41+
//insta, err := goinsta.Import("~/.goinsta")
42+
insta := goinsta.New("USERNAME", "PASSWORD")
4843

49-
if err := insta.Login(); err != nil {
50-
fmt.Println(err)
51-
return
52-
}
53-
defer insta.Logout()
44+
// also you can use New function from gopkg.in/ahmdrz/goinsta.v2/utils
5445

55-
...
46+
// insta.SetProxy("http://localhost:8080", true) // true for insecure connections
47+
if err := insta.Login(); err != nil {
48+
fmt.Println(err)
49+
return
50+
}
51+
// export your configuration
52+
// after exporting you can use Import function instead of New function.
53+
insta.Export("~/.goinsta")
54+
55+
...
5656
}
5757
```
5858

59-
In the next examples you can use an optional argument to use cache config.
59+
* [**More Examples**](https://github.com/ahmdrz/goinsta/tree/master/examples)
60+
61+
### Projects using `goinsta`
6062

61-
* [**More Examples**](https://github.com/ahmdrz/goinsta/tree/v2/examples)
63+
- [instagraph](https://github.com/ahmdrz/instagraph)
64+
- [icrawler](https://github.com/themester/icrawler)
65+
- [go-instabot](https://github.com/tducasse/go-instabot)
66+
- [ermes](https://github.com/borteo/ermes)
67+
- [nick\_bot](https://github.com/icholy/nick_bot)
68+
- [goinstadownload](https://github.com/alejoloaiza/goinstadownload)
69+
- [instafeed](https://github.com/falzm/instafeed)
70+
- [keepig](https://github.com/seankhliao/keepig)
71+
- ...
6272

63-
## Legal
73+
### Legal
6474

6575
This code is in no way affiliated with, authorized, maintained, sponsored or endorsed by Instagram or any of its affiliates or subsidiaries. This is an independent and unofficial API. Use at your own risk.
6676

67-
## Donate
77+
### Versioning
78+
79+
Goinsta used gopkg.in as versioning control. Stable new API is the version v2.0. You can get it using:
80+
```bash
81+
go get -u -v gopkg.in/ahmdrz/goinsta.v2
82+
```
83+
84+
### New version !
85+
86+
We are working on a new object-oriented API. Try it and tell us your suggestions. See https://github.com/ahmdrz/goinsta/blob/master/CONTRIBUTING.md
87+
88+
If you want to use the old version you can found it in v1 branch or using gopkg.in/ahmdrz/goinsta.v1/
89+
90+
Sorry for breaking dependences :(. You can use this command in your project folder to update old master branch to v1.
91+
92+
```bash
93+
for i in `grep -r ahmdrz ./ | awk '{split($0, a, ":"); print a[1]}'`; do sed -i 's/github\.com\/ahmdrz\/goinsta/gopkg\.in\/ahmdrz\/goinsta\.v1/g' $i; done
94+
```
95+
96+
### Donate
6897

6998
**Ahmdrz**
7099

@@ -75,38 +104,5 @@ This code is in no way affiliated with, authorized, maintained, sponsored or end
75104
![btc](https://raw.githubusercontent.com/reek/anti-adblock-killer/gh-pages/images/bitcoin.png) Bitcoin: `37aogDJYBFkdSJTWG7TgcpgNweGHPCy1Ks`
76105

77106

78-
79107
[![Analytics](https://ga-beacon.appspot.com/UA-107698067-1/readme-page)](https://github.com/igrigorik/ga-beacon)
80108

81-
82-
## Schema
83-
84-
Instagram
85-
- Account: Personal information and account interactions.
86-
- Followers
87-
- Following
88-
- Feed
89-
- Stories
90-
- Liked
91-
- Saved
92-
- Tags
93-
- Profiles: User interaction.
94-
- Blocked
95-
- Get user using ID
96-
- Get user using Username
97-
- Media:
98-
- Comments
99-
- Likes
100-
- Likers
101-
- Search:
102-
- Location
103-
- Username
104-
- Tags
105-
- Location **Deprecated**
106-
- Facebook
107-
- Activity:
108-
- Following
109-
- Recent
110-
- Hashtag: Hashtag allows user to search using hashtags.
111-
- Stories
112-
- Media

account.go

+44-11
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type Account struct {
5454
SocialContext string `json:"social_context,omitempty"`
5555
SearchSocialContext string `json:"search_social_context,omitempty"`
5656
MutualFollowersCount float64 `json:"mutual_followers_count"`
57-
LatestReelMedia int `json:"latest_reel_media,omitempty"`
57+
LatestReelMedia int64 `json:"latest_reel_media,omitempty"`
5858
CityID int64 `json:"city_id"`
5959
CityName string `json:"city_name"`
6060
AddressStreet string `json:"address_street"`
@@ -77,14 +77,11 @@ func (account *Account) Sync() error {
7777
if err != nil {
7878
return err
7979
}
80-
81-
body, err := insta.sendRequest(
82-
&reqOptions{
83-
Endpoint: urlSyncProfile,
84-
Query: generateSignature(data),
85-
IsPost: true,
86-
},
87-
)
80+
body, err := insta.sendRequest(&reqOptions{
81+
Endpoint: urlCurrentUser,
82+
Query: generateSignature(data),
83+
IsPost: true,
84+
})
8885
if err == nil {
8986
resp := profResp{}
9087
err = json.Unmarshal(body, &resp)
@@ -246,17 +243,27 @@ func (account *Account) Following() *Users {
246243

247244
// Feed returns current account feed
248245
//
246+
// params can be:
247+
// string: timestamp of the minimum media timestamp.
248+
//
249249
// minTime is the minimum timestamp of media.
250250
//
251251
// For pagination use FeedMedia.Next()
252-
func (account *Account) Feed(minTime []byte) *FeedMedia {
252+
func (account *Account) Feed(params ...interface{}) *FeedMedia {
253253
insta := account.inst
254254

255255
media := &FeedMedia{}
256256
media.inst = insta
257-
media.timestamp = string(minTime)
258257
media.endpoint = urlUserFeed
259258
media.uid = account.ID
259+
260+
for _, param := range params {
261+
switch s := param.(type) {
262+
case string:
263+
media.timestamp = s
264+
}
265+
}
266+
260267
return media
261268
}
262269

@@ -312,10 +319,36 @@ func (account *Account) Saved() (*SavedMedia, error) {
312319
return nil, err
313320
}
314321

322+
type editResp struct {
323+
Status string `json:"status"`
324+
Account Account `json:"user"`
325+
}
326+
327+
func (account *Account) edit() {
328+
insta := account.inst
329+
acResp := editResp{}
330+
body, err := insta.sendRequest(
331+
&reqOptions{
332+
Endpoint: urlCurrentUser,
333+
Query: map[string]string{
334+
"edit": "true",
335+
},
336+
},
337+
)
338+
if err == nil {
339+
err = json.Unmarshal(body, &acResp)
340+
if err == nil {
341+
acResp.Account.inst = insta
342+
*account = acResp.Account
343+
}
344+
}
345+
}
346+
315347
// SetBiography changes your Instagram's biography.
316348
//
317349
// This function updates current Account information.
318350
func (account *Account) SetBiography(bio string) error {
351+
account.edit() // preparing to edit
319352
insta := account.inst
320353
data, err := insta.prepareData(
321354
map[string]interface{}{

0 commit comments

Comments
 (0)