This repository was archived by the owner on Aug 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 246
Fix upload photo #296
Open
manslaughter03
wants to merge
5
commits into
ahmdrz:master
Choose a base branch
from
manslaughter03:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix upload photo #296
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8664a60
fix upload feature
manslaughter03 b49ce19
add upload photo example
manslaughter03 9e93298
update cookie url to base url in order to upload photo with cookies l…
manslaughter03 9ed02ad
fix path import on upload-photo example
manslaughter03 aed82b2
add UploadVideo to media goinsta function, add example too
manslaughter03 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "log" | ||
| "net/http" | ||
| "os" | ||
|
|
||
| "github.com/ahmdrz/goinsta" | ||
| ) | ||
|
|
||
| func main() { | ||
| insta := goinsta.New( | ||
| os.Getenv("INSTAGRAM_USERNAME"), | ||
| os.Getenv("INSTAGRAM_PASSWORD"), | ||
| ) | ||
| if err := insta.Login(); err != nil { | ||
| log.Fatal(err) | ||
| } | ||
|
|
||
| defer insta.Logout() | ||
|
|
||
| log.Println("Download random photo") | ||
| var client http.Client | ||
| request, err := http.NewRequest("GET", "https://picsum.photos/800/800", nil) | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
| resp, err := client.Do(request) | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
|
|
||
| defer resp.Body.Close() | ||
|
|
||
| postedPhoto, err := insta.UploadPhoto(resp.Body, "awesome! :)", 1, 1) | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
|
|
||
| log.Printf("Success upload photo %s", postedPhoto.ID) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "log" | ||
| "net/http" | ||
| "os" | ||
|
|
||
| "github.com/TheForgotten69/goinsta/v2" | ||
| ) | ||
|
|
||
| func main() { | ||
| insta := goinsta.New( | ||
| os.Getenv("INSTAGRAM_USERNAME"), | ||
| os.Getenv("INSTAGRAM_PASSWORD"), | ||
| ) | ||
| if err := insta.Login(); err != nil { | ||
| log.Fatal(err) | ||
| } | ||
|
|
||
| defer insta.Logout() | ||
|
|
||
| log.Println("Download random photo") | ||
| var client http.Client | ||
| request, err := http.NewRequest("GET", "https://picsum.photos/800/800", nil) | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
| thumbnail, err := client.Do(request) | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
|
|
||
| defer thumbnail.Body.Close() | ||
|
|
||
| log.Println("Download random video") | ||
| request, err = http.NewRequest("GET", "https://www.w3toys.com/download.php?url=https%3A%2F%2Fscontent-cdt1-1.cdninstagram.com%2Fv%2Ft50.2886-16%2F142537180_690913001575458_6043626278285741826_n.mp4%3F_nc_ht%3Dscontent-cdt1-1.cdninstagram.com%26_nc_cat%3D106%26_nc_ohc%3DtngasMRSAgsAX-kTy42%26oe%3D60197438%26oh%3De81483acbdfa4570a433c74544c6edc0%26dl%3D1", nil) | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
| video, err := client.Do(request) | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
|
|
||
| defer video.Body.Close() | ||
|
|
||
| postedVideo, err := insta.UploadVideo(video.Body, "awesomeVID", "awesome! :)", thumbnail.Body) | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
|
|
||
| log.Printf("Success upload video %s", postedVideo.ID) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I add this random number to generate name of the upload (part of url) and then use as value of 'X-Entity-Name' header. I use the same range used by https://github.com/dilame/instagram-private-api/blob/master/src/repositories/upload.repository.ts#L20. When i listen instagram api call from app, the requested url for upload fit this generate string.