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

Commit

Permalink
Sync with master branch. (#219)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ahmdrz authored Mar 21, 2019
1 parent 73746e1 commit cf89031
Show file tree
Hide file tree
Showing 111 changed files with 2,551 additions and 934 deletions.
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Contribution

Welcome programmer!

If you want to contribute to Goinsta API you must follow a simple instructions.

- **Test your code after making pull request**. The title says it all.
- **Include jokes if you can**. This instruction is optional.
11 changes: 0 additions & 11 deletions CONTRIBUTION.md

This file was deleted.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Ahmadreza Zibaei

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
114 changes: 55 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,99 @@
# GoInsta. Make Goinsta Great Again!
<p align="center"><img width=100% src="https://raw.github.com/ahmdrz/goinsta/master/resources/goinsta-image.png"></p>
### Go + Instgaram API
<p align="center"><img width=100% src="https://raw.githubusercontent.com/ahmdrz/goinsta/v1/resources/goinsta-image.png"></p>

> Unofficial Instagram API for Golang
[![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)
[![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)

## Features
### Features

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

## New Version !

We are working on `alpha` branch. Try it and tell us your suggestions!

The newer versions will be exported into v2 branch when new features will be well tested.

## Package installation
### Package installation

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

## CLI installation
### CLI installation

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

## Example
### Example

```go
package main

import (
"fmt"

"github.com/ahmdrz/goinsta"
"gopkg.in/ahmdrz/goinsta.v2"
)

func main() {
insta := goinsta.New("USERNAME", "PASSWORD")
//insta, err := goinsta.Import("~/.goinsta")
insta := goinsta.New("USERNAME", "PASSWORD")

if err := insta.Login(); err != nil {
fmt.Println(err)
return
}
defer insta.Logout()
// also you can use New function from gopkg.in/ahmdrz/goinsta.v2/utils

...
// insta.SetProxy("http://localhost:8080", true) // true for insecure connections
if err := insta.Login(); err != nil {
fmt.Println(err)
return
}
// export your configuration
// after exporting you can use Import function instead of New function.
insta.Export("~/.goinsta")

...
}
```

In the next examples you can use an optional argument to use cache config.
* [**More Examples**](https://github.com/ahmdrz/goinsta/tree/master/examples)

### Projects using `goinsta`

* [**More Examples**](https://github.com/ahmdrz/goinsta/tree/v2/examples)
- [instagraph](https://github.com/ahmdrz/instagraph)
- [icrawler](https://github.com/themester/icrawler)
- [go-instabot](https://github.com/tducasse/go-instabot)
- [ermes](https://github.com/borteo/ermes)
- [nick\_bot](https://github.com/icholy/nick_bot)
- [goinstadownload](https://github.com/alejoloaiza/goinstadownload)
- [instafeed](https://github.com/falzm/instafeed)
- [keepig](https://github.com/seankhliao/keepig)
- ...

## Legal
### Legal

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.

## Donate
### Versioning

Goinsta used gopkg.in as versioning control. Stable new API is the version v2.0. You can get it using:
```bash
go get -u -v gopkg.in/ahmdrz/goinsta.v2
```

### New version !

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

If you want to use the old version you can found it in v1 branch or using gopkg.in/ahmdrz/goinsta.v1/

Sorry for breaking dependences :(. You can use this command in your project folder to update old master branch to v1.

```bash
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
```

### Donate

**Ahmdrz**

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



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


## Schema

Instagram
- Account: Personal information and account interactions.
- Followers
- Following
- Feed
- Stories
- Liked
- Saved
- Tags
- Profiles: User interaction.
- Blocked
- Get user using ID
- Get user using Username
- Media:
- Comments
- Likes
- Likers
- Search:
- Location
- Username
- Tags
- Location **Deprecated**
- Facebook
- Activity:
- Following
- Recent
- Hashtag: Hashtag allows user to search using hashtags.
- Stories
- Media
55 changes: 44 additions & 11 deletions account.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type Account struct {
SocialContext string `json:"social_context,omitempty"`
SearchSocialContext string `json:"search_social_context,omitempty"`
MutualFollowersCount float64 `json:"mutual_followers_count"`
LatestReelMedia int `json:"latest_reel_media,omitempty"`
LatestReelMedia int64 `json:"latest_reel_media,omitempty"`
CityID int64 `json:"city_id"`
CityName string `json:"city_name"`
AddressStreet string `json:"address_street"`
Expand All @@ -77,14 +77,11 @@ func (account *Account) Sync() error {
if err != nil {
return err
}

body, err := insta.sendRequest(
&reqOptions{
Endpoint: urlSyncProfile,
Query: generateSignature(data),
IsPost: true,
},
)
body, err := insta.sendRequest(&reqOptions{
Endpoint: urlCurrentUser,
Query: generateSignature(data),
IsPost: true,
})
if err == nil {
resp := profResp{}
err = json.Unmarshal(body, &resp)
Expand Down Expand Up @@ -246,17 +243,27 @@ func (account *Account) Following() *Users {

// Feed returns current account feed
//
// params can be:
// string: timestamp of the minimum media timestamp.
//
// minTime is the minimum timestamp of media.
//
// For pagination use FeedMedia.Next()
func (account *Account) Feed(minTime []byte) *FeedMedia {
func (account *Account) Feed(params ...interface{}) *FeedMedia {
insta := account.inst

media := &FeedMedia{}
media.inst = insta
media.timestamp = string(minTime)
media.endpoint = urlUserFeed
media.uid = account.ID

for _, param := range params {
switch s := param.(type) {
case string:
media.timestamp = s
}
}

return media
}

Expand Down Expand Up @@ -312,10 +319,36 @@ func (account *Account) Saved() (*SavedMedia, error) {
return nil, err
}

type editResp struct {
Status string `json:"status"`
Account Account `json:"user"`
}

func (account *Account) edit() {
insta := account.inst
acResp := editResp{}
body, err := insta.sendRequest(
&reqOptions{
Endpoint: urlCurrentUser,
Query: map[string]string{
"edit": "true",
},
},
)
if err == nil {
err = json.Unmarshal(body, &acResp)
if err == nil {
acResp.Account.inst = insta
*account = acResp.Account
}
}
}

// SetBiography changes your Instagram's biography.
//
// This function updates current Account information.
func (account *Account) SetBiography(bio string) error {
account.edit() // preparing to edit
insta := account.inst
data, err := insta.prepareData(
map[string]interface{}{
Expand Down
Loading

0 comments on commit cf89031

Please sign in to comment.