them4hd1 / swiftyinsta Goto Github PK
View Code? Open in Web Editor NEWInstagram Private API Swift
License: MIT License
Instagram Private API Swift
License: MIT License
I added "archive/reel/day_shells/" but I cannot get /feed/reels_media/ with "user_ids" ([archiveDay:18014492728127***])
{ "timestamp": 1550275300, "media_count": 9, "id": "archiveDay:18014492728127***", "reel_type": "archive_day_reel", "latest_reel_media": 15503425** }
{"message": "Invalid reel id list", "status": "fail"}
Hi,
I have got error while getting users.recentactivities response. I am using pod version 2.01 (latest for now)
I am new to the library may be I am doing something wrong or the response is not valid I am not sure yet so I decided to create an issue for that.
In short it says : Expected to decode Data but found a dictionary instead.
Do i need to make another variable different than result in completionhandler or response is not valid in the library?
Here is my code and the error I got ;
(I have already authenticated and I can get followers list without any problem)
handler.users.recentActivities(
with: .init(maxPagesToLoad: .max),
updateHandler: nil,
completionHandler: {result, _ in
print(result)
})
When i add breakpoint at print line I can see a failure and error ;
Printing description of result:
▿ Result<Array, Error>
▿ failure : DecodingError
▿ typeMismatch : 2 elements
- .0 : Foundation.Data
▿ .1 : Context
▿ codingPath : 4 elements
- 0 : CodingKeys(stringValue: "aymf", intValue: nil)
- 1 : CodingKeys(stringValue: "items", intValue: nil)
▿ 2 : _JSONKey(stringValue: "Index 0", intValue: 0)
- stringValue : "Index 0"
▿ intValue : Optional
- some : 0
- 3 : CodingKeys(stringValue: "user", intValue: nil)
- debugDescription : "Expected to decode Data but found a dictionary instead."
- underlyingError : nil
Ciao
I am trying to add multiple account feature.
What i am trying to do is basically: Save cookies with user defaults with the key userPk
But the problem is, when i am trying to add 2nd user, it brings back first user's cookies
(somehow and although i delete all cookies) it shows me first user's feed.... So i can't even login for the second user
Any idea on how to fix this?
In new version you added second arguments in closure body.
What is for second one? And how can I call it?
When I try to call like this it gives error
try handler.getUserFollowers(userId: userId, maxId: "" , searchQuery: "", completion: { (result) in
print(result)
})
i try to get 4K - 5K followers via your api but it takes too long time.how can i speed this up ? can u have some way to give me all followers like bulk one time ?
Right now library is using always fake user-agent (Samsung C660). Can we use real one from device?
Do we really need to use delay on requests?
I thought of maybe adding some tags to the repository for easier discoverability.
Something like #swift, #instagram, #api, #cocoapods or sth along these lines… idk.
What do you think? @TheM4hd1
And I would also consider moving the url to the README
. It feels misplaced in the description, imho. But it's just an opinion though.
I can get my stories with getUserStory.
How can I get story url to show in my app?
When I call try handler.getUserFollowers(userId: userId, maxId: nextPageId, searchQuery: "", completion: { (result, maxId)
after 298 nd request its gaves error like:
Result(isSucceeded: false, info: SwiftyInsta.ResultInfo(error: SwiftyInsta.CustomErrors.noError, message: "The operation couldn’t be completed. (SwiftyInsta.CustomErrors error 9.)", responseType: SwiftyInsta.ResponseTypes.wrongRequest), value: nil)
PS: I already remove delay. With delay method it is working
Could you please make this compatible with the apple watch? It doesn't like the length of the user pk. Thanks :)
When I call handler.getUser function it returns 12710 and it is correct but when I call
handler.getUserFollowers returns 12702. 8 user are missing.
When I call getUser function its value status return fail and user value is nil
Any example with pagination ?
Hi,
getMediaLikers and getMediaComments methods not working anymore. Before it was working smoothly but now not
Can you add support for caching logged in user , to avoid to login every time the app is launched ?
Originally posted by @AlexisBarreyat in #3 (comment)
Most of the functions like getUserFollowers, getUserFollowing, getUserMedia, etc. first searches for the specific username on the Instagram and then finds the first match and then returns it.
But the thing is, what happens if I have a commonly used username like "funny" where the search result doesn't bring the actual user with username "funny" but instead returns a different account?
This is an important issue that needs to be addressed. If you need further clarification, I can give full details.
Great repo.
Is there any way we could have story highlights added as well?
I tried to login and it failed. failed message is "too many HTTP redirects"
{"message": "Sorry, there was a problem with your request.", "status": "fail", "error_type": "sentry_block"}
[-] Login failed: unExpected("sentry_block")
is there something im doing wrong thats causing the sentry block, is there something i can do to prevent the sentry block?
let user = SessionStorage.create(username: "\(String(username!))", password: "\(String(password!))")
let userAgent = CustomUserAgent(apiVersion: "89.0.0.0", osName: "iOS", osVersion: "12", osRelease: "1.4", dpi: "458", resolution: "2688x1242", company: "Apple", model: "iPhone10,3", modem: "intel", locale: "en_US", fbCode: "95414346")
HttpSettings.shared.addValue(userAgent.toString(), forHTTPHeaderField: Headers.HeaderUserAgentKey)
let urlSession = URLSession(configuration: .default)
let handler = try! APIBuilder().createBuilder().setHttpHandler(urlSession: urlSession).setRequestDelay(delay: .default).setUser(user: user).build()
var _error: Error?
do {
try handler.login { (result, cache) in
if result.isSucceeded {
DispatchQueue.main.async {
self.statusLabel!.text = "logged in"
self.bubbleColor!.image = UIImage(named: "bubble_green")
self.statusText!.textColor = UIColor(red:0.22, green:0.64, blue:0.04, alpha:1.0)
}
print("[+]: logged in")
} else {
print("[-] Login failed: \(result.info.error)")
_error = result.info.error
DispatchQueue.main.async {
self.statusLabel!.text = "login failed"
self.errorLabel!.text = "\(_error!)"
self.bubbleColor!.image = UIImage(named: "bubble_red")
self.statusText!.textColor = UIColor(red:0.91, green:0.06, blue:0.06, alpha:1.0)
}
}
}
}
There is no method to view the history, so that it is marked as viewed. How I can do this?
After update the pod weblogin not compiled in ios 10 version.
When I change to 11.0 version of ios it says:
InstagramLoginWebView
properties instead.InstagramLoginWebViewProtocol
closure properties instead.When I changed InstagramLoginWebViewDelegate to InstagramLoginWebViewProtocol:
My Codes:
class LoginViewController: UIViewController {
var loginWebView: InstagramLoginWebView! = nil
override func viewDidLoad() {
super.viewDidLoad()
loginWebView = InstagramLoginWebView(frame: self.view.frame)
self.view.addSubview(loginWebView!)
loginWebView?.loginDelegate = self **-- Cannot assign value of type 'LoginViewController' to type 'InstagramLoginWebViewDelegate?'**
self.loginWebView?.loadInstagramLogin(isNeedPreloadForCookieSync: true) **--Argument passed to call that takes no arguments**
}
}
extension LoginViewController : InstagramLoginWebViewProtocol { --'InstagramLoginWebViewProtocol' requires that 'LoginViewController' inherit from 'UIView'
func userLoggedSuccessfully() {
print("User Logged Successfully")
DispatchQueue.main.async {
self.loginWebView.removeFromSuperview()
}
}
I am trying to get media likers . Function is working nice and I can see the results with breakpoint. But when I try to get items in model I can not access it.
my codes:
let users = result.value.map({ $0.users! }) -> It gives an error like 'users' is inaccessible due to 'internal' protection level
and I try to access it with:
result.value.users -> It says Value of type 'MediaLikersModel?' has no member 'users'
How can I get the users who like media?
Is there any way to see old stories which is not in story feed anymore?
On Instagram:
When I click to add story button instagram show the old stories which is sharing before.
follow api dismiss
I feel like implementing Travis CI
might be a good idea, especially with all the changes that are being discussed for 2.0
.
Just an opinion though.
Hi,
When I try to get user all media with getUserMedia method it returns only first page and it is not using nextid.
How can we fix it?
Thanks
Result<Array>(isSucceeded: true, info: InstaWatch.ResultInfo(error: InstaWatch.CustomErrors.noError, message: "", responseType: InstaWatch.ResponseTypes.ok), value: Optional([]))
I've seen this feature available for Instagram-API-Python on a PR. Maybe it could be done for Swift as well.
I tried several combinations of the payload like
usertags: [{ user_id: 0000, x: 0.1, y 0.1}]
usertags: [{ user_id: 0000, position: [0.1,0.1]}]
But none of my combinations work. Maybe it needs an extra step that I cannot see right now that I just starting using this library.
Hey @TheM4hd1 😊 thanks for making this great library (and Siwa
, which is even more impressive), you've done an amazing job thus far. And thanks for letting me tag along and help.
With 2.0
approaching I was wondering what was the great scheme of things, if there were milestones planned or particular features you were thinking of implementing. Cause after using this for a while I have some suggestions that might make it in a bigger update:
.shared
, allowing users to run multiple accounts at the same time [I might start working on this today or tomorrow, if it's ok] ✓private
or internal
✓development
branch where we can push approved pull requests in order to test everything better before pushing it to the master (2.0
is definitely a big deal 😊) ✓userId
, pk
, userPk
... and uniforming parameters names (I know I made it worse with completionHandler
vs completion
, but I feel like UserReference
kinda makes it even hahaha), as well making functions more "swift-y" (using named parameters, etc.) ✓some Protocol
pattern would be great for solving most of the login "issues"Just some ideas though. Please let me know what priorities you have and how to help you.
Peace ✌️
Can we add the feature provides that reaching logged in user's stories' viewer list ?
@sbertix func isUserLoggedIn(instagramCookies : [HTTPCookie]?)
recieves only 2 cookies. That's the reason why it doesn't login. And when it recieves 6 cookies, it works. It's just a matter of luck 😄
Here is my flow
var webView: InstagramLoginWebView? {
didSet {
oldValue?.removeFromSuperview()
guard let webView = webView else { return }
view.addSubview(webView)
// always request log in page when setting a new web view.
webView.loadInstagramLogin()
webView.fillToSuperview()
}
}
override func viewDidLoad() {
super.viewDidLoad()
InstagramLoginWebView.create(with: self.view.bounds, didReachEndOfLoginFlow: nil,
didSuccessfullyLogIn: {
self.showProfileVC()
}, completionHandler: { (cache, handlerProtocol) in
//do stuff
}, returnHandler: {[weak self] in self?.webView = $0 })
}
As suggested in #50, we should start considering a better approach for models, in time for 2.0
Right now they directly represent the parsed JSON response, which is especially uncomfortable when dealing with media and users (and all their different definitions inside the library).
I'm proposing the following, as an improvement of the current situation.
Any model should conform to ParsedResponse
defined as following:
public protocol ParsedResponse {
associatedtype RawResponse: Codable
var rawResponse: RawResponse { get }
}
Where RawResponse
might just as well represent the current models (or even a Dictionary
tbh..., idk).
I would not enforce Codable
on ParsedResponse
but maybe add an init
with the associated RawResponse
as an argument, but I'm open to suggestions.
Every "parsed" attribute can therefore be achieved through accessories of the ParsedResponse
, either as run-time read-only get
var
s or let
constants computed on init
(depending on their computational difficulty).
(bonus: No more UserModel
, CurrentUserModel
, UserShortModel
, etc.)
Suggestions? Opinions?
I might start working on this tomorrow.
I need to upload video to Instagram. Please let me know how can I do it.
Thanks
Alok
func followUser(userId: Int, completion: @escaping (Result<FollowResponseModel>) -> ())
stopped working. There is no error. It just doesn't make us follow the user.
when trying to get user info Xcode 10 just throws an EXC_BAD_ACCESS (code=EXC_I386_GPFLT) error even when using the get user from tests
Can we use instagram mobile login web page as a login method ?
returns 0 bytes - code 405
How I can get list of users who liked or commented given post? I looked at all models and can't find any relevant info in them.
Login failed if the password includes special characters like (+,-). But if it is not, works like a charm..
try to login with a new registered fresh user. web login not completed sometimes randomly. Instagram shows a different user suggestion page. I try to follow 1 user, also 1 user followed me (it shows feed but not worked) mostly web login was not completed for this user. After trying 2-3 times to login it may work.
[DONE IN SwiftyInsta
v. 2.0
]
The login mechanics used in Siwa are far superior to the ones in SwiftyInsta
, yet SwiftyInsta
still provides a way for headless login, only resulting in code duplication.
Instead of dropping support for authentication through username and password from SwiftyInsta
(like I proposed in my draft for 2.0
now in the development
branch), why not adding all of Siwa
functionalities back to SwiftyInsta
?
What's the reasoning behind having them as separate frameworks?
I see a method 'getUserFollowers' to get followers with detail but please can you help me get FollowerCount , FollowingCount and TotalPhotosCount directly from Login Call ?!!
The getTimeLineList(from:_,list:_,…)
retrieves a 405 error code
response, thus returning an empty list.
(Tested on iOS 13)
Hey Mahdi,
I wonder about could you add the feature that provides search users. Like search keyword Mahdi returns many of people like instagram search ?
Thank you..
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.