All Projects → shyambhat → Instagramkit

shyambhat / Instagramkit

Licence: mit
The unofficial Instagram iOS SDK

Projects that are alternatives of or similar to Instagramkit

Flowing Gradient
Android Library to make a flowing gradient effect, similar to that used in Instagram Android login screen
Stars: ✭ 701 (-26.6%)
Mutual labels:  instagram
Stealing Ur Feelings
Winner of Mozilla's $50,000 prize for art and advocacy exploring AI
Stars: ✭ 784 (-17.91%)
Mutual labels:  instagram
Instagram Scraper
Scrape the Instagram frontend. Inspired from twitter-scraper by @kennethreitz.
Stars: ✭ 903 (-5.45%)
Mutual labels:  instagram
Goinsta
Unofficial Instagram API written in Golang
Stars: ✭ 733 (-23.25%)
Mutual labels:  instagram
Storiesprogressview
show horizontal progress like instagram stories.
Stars: ✭ 762 (-20.21%)
Mutual labels:  instagram
Papergram
Set Instagram backgrounds on iOS
Stars: ✭ 5 (-99.48%)
Mutual labels:  instagram
Socialmanagertools Igbot
🤖 📷 Instagram Bot made with love and nodejs
Stars: ✭ 699 (-26.81%)
Mutual labels:  instagram
Instagrid Js
A Javascript library to do exactly what Instagram Layout application does
Stars: ✭ 13 (-98.64%)
Mutual labels:  instagram
React Insta Stories
A React component for Instagram like stories
Stars: ✭ 777 (-18.64%)
Mutual labels:  instagram
Instabiosquotes
Completely FREE Instagram Bio and Quotes Android App with latest collection of Instagram Bio and Instagram quotes for setting as your status.
Stars: ✭ 17 (-98.22%)
Mutual labels:  instagram
Photo Editor
Photo editor with a lot of cool features
Stars: ✭ 753 (-21.15%)
Mutual labels:  instagram
React Instagram Clone 2.0
A reactive Single-Page Instagram-Clone with some new features!! 💪📸👓
Stars: ✭ 756 (-20.84%)
Mutual labels:  instagram
Vintagejs
Add a retro/vintage effect to images using the HTML5 canvas element
Stars: ✭ 826 (-13.51%)
Mutual labels:  instagram
Barinsta
Open-source alternative Instagram client on Android.
Stars: ✭ 717 (-24.92%)
Mutual labels:  instagram
Instagramfirstcommenter
This bot will post a predefined comment as fast as possible to a new post on the target profile. I used this to successfully win tickets for a big music festival.
Stars: ✭ 26 (-97.28%)
Mutual labels:  instagram
Instagram Web Api
🤳 Instagram Private Web API client for Node
Stars: ✭ 694 (-27.33%)
Mutual labels:  instagram
Instagram Profilecrawl
📝 quickly crawl the information (e.g. followers, tags etc...) of an instagram profile.
Stars: ✭ 816 (-14.55%)
Mutual labels:  instagram
Envchain
Environment variables meet macOS Keychain and gnome-keyring <3
Stars: ✭ 876 (-8.27%)
Mutual labels:  keychain
Social ids
Get user ids from social network handlers
Stars: ✭ 9 (-99.06%)
Mutual labels:  instagram
Instagram Terminal News Feed
Instagram in terminal 👽👽🔥🔥
Stars: ✭ 892 (-6.6%)
Mutual labels:  instagram

InstagramKit

CI Status Version License Platform

Carthage compatible Apps Using Downloads Twitter: @bhatthead

An extensive Objective C wrapper for the Instagram API, completely compatible with Swift.

Here's a quick example to retrieve trending media on Instagram:

InstagramEngine *engine = [InstagramEngine sharedEngine];
[engine getPopularMediaWithSuccess:^(NSArray *media, InstagramPaginationInfo *paginationInfo) {
// media is an array of InstagramMedia objects
...
} failure:^(NSError *error, NSInteger statusCode) {
...
}];

The framework is built atop AFNetworking’s blocks-based architecture and additionally, parses JSON data and creates model objects asynchronously so there’s absolutely no parsing on the main thread. It’s neat, fast and works like a charm.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

InstagramKit is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'InstagramKit'

If your App uses authorization and you'd like the storage and retrieval of the access token in the Keychain to be automatically handled for you by UICKeyChainStore, include the following lines instead -

pod 'InstagramKit'
pod 'InstagramKit/UICKeyChainStore'

InstagramKit uses UICKeyChainStore as an optional sub-dependency for Keychain access. If you opt to use the optional pod, InstagramKit resumes your authenticated sessions across App launches, without needing any additional code.

Instagram Developer Registration

Head over to http://instagram.com/developer/clients/manage/ to register your app with Instagram and set the right credentials for InstagramAppClientId and InstagramAppRedirectURL in your App's Info.plist file.

InstagramAppClientId is your App's Client Id and InstagramAppRedirectURL, the redirect URI which is obtained on registering your App on Instagram's Developer Dashboard. The redirect URI specifies where Instagram should redirect users after they have chosen whether or not to authenticate your application.

Instagram Platform Updates

Instagram frequently updates its APIs and deprecates endpoints that are in use. If you see a 400 or other strange errors from the server response, please check on Instagram's API changelog and create an issue with your findings. https://www.instagram.com/developer/changelog/

Usage

Authentication

For each API call, you will need an Access Token and specific scope permissions. To get the Access Token, the user needs to authenticate your app to access his Instagram account with the specified permissions.

To do so, redirect the user to https://instagram.com/oauth/authorize/?client_id=[Client ID]&redirect_uri=[Redirect URI]&response_type=token or allow InstagramEngine's helper method do the hard work for you -

NSURL *authURL = [[InstagramEngine sharedEngine] authorizationURL];
[self.webView loadRequest:[NSURLRequest requestWithURL:authURL]];

Scopes

All apps have basic read access by default, but if you plan on asking for extended access such as liking, commenting, or managing friendships, you need to specify these scopes in your authorization request using the InstagramKitScope enum.

Note that in order to use these extended permissions, first you need to submit your app for review to Instagram.

For your app to POST or DELETE likes, comments or follows, you must apply to Instagram here : https://www.facebook.com/help/instagram/contact/185819881608116#

// Set scope depending on permissions your App has been granted from Instagram
// InstagramKitLoginScopeBasic is included by default.

InstagramKitLoginScope scope = InstagramKitLoginScopeRelationships | InstagramKitLoginScopeComments | InstagramKitLoginScopeLikes; 

NSURL *authURL = [[InstagramEngine sharedEngine] authorizationURLForScope:scope];
[self.webView loadRequest:[NSURLRequest requestWithURL:authURL]];

Once the user grants your app permission, they will be redirected to a url in the form of something like http://localhost/#access_token=[access_token] and [access_token] will be split by a period like [userID].[rest of access token]. InstagramEngine includes a helper method to validate this token.

UIWebView

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSError *error;
if ([[InstagramEngine sharedEngine] receivedValidAccessTokenFromURL:request.URL error:&error]) {
// success!
...
}
return YES;
}
WKWebView

- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(nonnull WKNavigationAction *)navigationAction decisionHandler:(nonnull void (^)(WKNavigationActionPolicy))decisionHandler
{   
NSError *error;
if ([[InstagramEngine sharedEngine] receivedValidAccessTokenFromURL:navigationAction.request.URL error:&error]) {
// success!
...
}    
decisionHandler(WKNavigationActionPolicyAllow);
}

Authenticated Requests

Once you're authenticated and InstagramKit has been provided an accessToken, it will automatically persist it until you call -logout on InstagramEngine. An authenticated call looks no different:

InstagramEngine *engine = [InstagramEngine sharedEngine];
[engine getSelfRecentMediaWithSuccess:^(NSArray *media, InstagramPaginationInfo *paginationInfo) {
// media is an array of InstagramMedia objects
...
} failure:^(NSError *error, NSInteger statusCode) {
...
}];

Pagination

The InstagramPaginationInfo object has everything it needs to make your next pagination call.

If you need to make fetch a paginated feed of results, use the variation of the method which accepts count and maxId as parameters. For instance, use getMediaForUser:count:maxId:withSuccess:failure: passing the next maxID to the maxId parameter each time, obtained from paginationInfo.nextMaxId of the newest paginationInfo object.

[engine getMediaForUser:user.Id 
count:15 
maxId:self.currentPaginationInfo.nextMaxId 
withSuccess:^(NSArray *media, InstagramPaginationInfo *paginationInfo) 
{
if (paginationInfo) {
self.currentPaginationInfo = paginationInfo;
}
...
} 
failure:^(NSError *error) 
{
...
}];

The first request will go with maxId as nil.

Each endpoint in the Instagram API that supports pagination, usually supports a count parameter. You can use this method and pass a count parameter to each paginated request. You can also use it in cases where you do not need pagination, but need to specify a feed count to the first request.

Read in detail about more ways of implementing Pagination for your requests effortlessly in the Pagination Wiki.

Contributions?

Glad you asked. Check out the open Issues and jump right in.

Questions?

The Instagram API Documentation is your definitive source of information in case something goes wrong. Please make sure you've read up the documentation before posting issues.

Author

Shyam Bhat, [email protected] Twitter: @bhatthead

License

InstagramKit is available under the MIT license. See the LICENSE file for more info.

==================

InstagramKit uses the public Instagram API and is not affiliated with either Instagram or Facebook.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].