crino / instagram-ios-sdk Goto Github PK
View Code? Open in Web Editor NEWInstagram SDK for iOS
Home Page: http://www.followgram.me
Instagram SDK for iOS
Home Page: http://www.followgram.me
When a view is loaded, I send out 2 requests, 1st is requesting for users/self/feed" (user feed), and 2nd is requesting for "users/self" (user info).
Those 2 requests may not be returned in the order that I have requested them. Is there a way that I can differentiate between the 2 requests since Instagram always returns the JSON dictionary as "data"?
Otherwise the next solution I can think of, which I don't prefer, is to wait till I receive the results of the 1st request before I start sending the 2nd request.
How can I use your sdk to post a like on a photo?
Thanks,
L
EDIT: Figured it out
`
-(void)likeImage:(NSString_)imageId
{
NSString_ methodName = [NSString stringWithFormat:@"media/%@/likes", imageId];
NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
[m_Instagram requestWithMethodName:methodName
params:params
httpMethod:@"POST"
delegate:self];
}
-(void)unlikeImage:(NSString_)imageId
{
NSString_ methodName = [NSString stringWithFormat:@"media/%@/likes", imageId];
NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
[m_Instagram requestWithMethodName:methodName
params:params
httpMethod:@"DELETE"
delegate:self];
}
`
Hi,
I'm using xcode 4.6.2 and have 2 problems with it. First, the project does not compile in a blank project, it says that can't synthesize weak references and the error persists even if i remove the synthesizes, i have to make the variables strong in order to work.
Second problem is that i'm trying to use it in a larger project, with fb integration also if matters, and get different 2 errors that i can't fix. Your example works instead but i can't see any difference in settings. Thanks
Ld /Users/Cristi/Library/Developer/Xcode/DerivedData/Instaslider-aqebwmejbvqneyakujwnvwcbpaal/Build/Products/Debug-iphoneos/Instaslider.app/Instaslider normal armv7
cd /Users/Cristi/Documents/iphone/Instaslider
setenv IPHONEOS_DEPLOYMENT_TARGET 6.0
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/opt/local/bin:/opt/local/sbin:/Applications/Xcode.app/Contents/Developer/usr/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -L/Users/Cristi/Library/Developer/Xcode/DerivedData/Instaslider-aqebwmejbvqneyakujwnvwcbpaal/Build/Products/Debug-iphoneos -F/Users/Cristi/Library/Developer/Xcode/DerivedData/Instaslider-aqebwmejbvqneyakujwnvwcbpaal/Build/Products/Debug-iphoneos -F/Users/Cristi/Documents/iphone/Instaslider/../../facebook-ios-sdk/build -filelist /Users/Cristi/Library/Developer/Xcode/DerivedData/Instaslider-aqebwmejbvqneyakujwnvwcbpaal/Build/Intermediates/Instaslider.build/Debug-iphoneos/Instaslider.build/Objects-normal/armv7/Instaslider.LinkFileList -dead_strip -lsqlite3.0 -ObjC -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=6.0 -framework CoreImage -framework CoreVideo -framework CoreMedia -weak_framework AdSupport -weak_framework Accounts -weak_framework Social -framework FacebookSDK -framework MediaPlayer -framework AVFoundation -framework AssetsLibrary -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/Cristi/Library/Developer/Xcode/DerivedData/Instaslider-aqebwmejbvqneyakujwnvwcbpaal/Build/Products/Debug-iphoneos/Instaslider.app/Instaslider
Undefined symbols for architecture armv7:
"OBJC_CLASS$_Instagram", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(null): "OBJC_CLASS$_Instagram", referenced from:
(null): Objc-class-ref in AppDelegate.o
(null): Symbol(s) not found for architecture armv7
(null): Linker command failed with exit code 1 (use -v to see invocation)
I noticed that if requestState == kIGRequestStateError, you invalidate the session. Isn't that a bit extreme? An error can happen for lots of reasons. To invalidate the entire session seems erroneous.
Instagram.m - line 104
right now when i am trying to open link in uiwebview its saying "Page not found you might have followed an incorrect link" earlier it was working fine.
thanks in advance.
Please create cocoa pod for the SDK.
I have been using this sdk for a while now and today it has started throwing errors. The error is displayed as an alert stating InstagramErrorDomain 10000. Upon further investigation it is an issue with parsing the JSON response from instagram, this parse fails as what was received was really html in the form of
I thought this might be an issue with my instagram account so I created a brand new one but still received this errors.
Any ideas?
For everyone who has the same question that I had, I figured it out so here is the method to follow a user in the wonderful example app by @crino !
First, in IGViewController.m you have to change the login methods so that the user authorizes the app to change relationships:
At the end of -(void)viewDidLoad add the @"relationships" scope in the array of authorization:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = [UIColor whiteColor];
UIButton* loginButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[loginButton setTitle:@"Login" forState:UIControlStateNormal];
[loginButton sizeToFit];
loginButton.center = CGPointMake(160, 200);
[loginButton addTarget:self
action:@selector(login)
forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:loginButton];
IGAppDelegate* appDelegate = (IGAppDelegate*)[UIApplication sharedApplication].delegate;
// here i can set accessToken received on previous login
appDelegate.instagram.accessToken = [[NSUserDefaults standardUserDefaults] objectForKey:@"accessToken"];
appDelegate.instagram.sessionDelegate = self;
if ([appDelegate.instagram isSessionValid]) {
IGListViewController* viewController = [[IGListViewController alloc] init];
[self.navigationController pushViewController:viewController animated:YES];
} else {
[appDelegate.instagram authorize:[NSArray arrayWithObjects:@"comments", @"likes",@"relationships", nil]]; //ADDED @"relationships" !
}
}
Next, also in IGViewController.m, in the -(void)login method, do the same thing:
-(void)login {
IGAppDelegate* appDelegate = (IGAppDelegate*)[UIApplication sharedApplication].delegate;
[appDelegate.instagram authorize:[NSArray arrayWithObjects:@"comments", @"likes",@"relationships", nil]]; ADDED @"relationships" again !
Then you can switch to the view controller where you want the user to follow another user
(WARNING: In the IGListViewController, the app crashes after running the follow method cause the "data" array changes and the table view can't show the followers anymore so I advise you to either use another view controller or to comment out all the tableView stuff in IGListViewController.m and in IGListViewController.h change "UITableViewController" to "UIViewController")
and, in the action you want, add the following code:
IGAppDelegate* appDelegate = (IGAppDelegate*)[UIApplication sharedApplication].delegate;
NSString *accessToken = [[NSUserDefaults standardUserDefaults]objectForKey:@"instagramAccessToken"];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"follow", @"action", accessToken , @"ACCESS_TOKEN" , nil];
[appDelegate.instagram requestWithMethodName:@"users/123456/relationship"
params:params
httpMethod:@"POST"
delegate:self];
Replace "123456" in the method name with the instagram ID of the user you want to follow (just go to this website to lookup any instagram id: http://jelled.com/instagram/lookup-user-id)
In order to unfollow, block, etc. a user just replace "follow" with the action from Instgaram API relationship endpoints.
Hope I forgot nothing if you still have questions or something doesn't work, just comment :)
Hi Crino
When we log out from our application then it end the scop of Auth but safari still hold the detail of logged in user, if we again go for log in then it will renew Auth with previously logged in user. How can we logged out from safari as well..?
Hi,
I get forbidden issue while login .
How can i upload photo to instagram with the SDK. or any other method.
I guess this is more of a question,
Is there a way to hold the active session once a user has authenticated. The situation is as follows : users logs in, everything works > user closes app and re opens a while later , app dies because it doesn't have the right session (error 400)
Is this possible in this sdk?
If I need send 2, 3 or more request from same ViewController, how I can do this? And how I can distinguish different data result in "request:(IGRequest *)request didLoad:(id)result"?
Hi i'm trying to connect with instagram but i'm getting the same error as previous issues :
"Redirect uri does not match the registered redirect uri"
but i'm sure it's the same uri where ig[Client Id]://authorize is redirection uri.
and in my plist file since i'm using also facebook in my test application see what I have in the image below
and in my delegate :
(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
if ([url.description hasPrefix:@"fb"])
{
return [[[FbManager sharedManager] facebook] handleOpenURL:url];
}
else
{
return [self.instagram handleOpenURL:url];
}
}
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
if ([url.description hasPrefix:@"fb"])
{
return [[[FbManager sharedManager] facebook] handleOpenURL:url];
}else
{
return [self.instagram handleOpenURL:url];
}
}
can anyone help please ?
Hi @crino , could you make this available on CocoaPods? Thanks.
Hi, can I have an example on how to login and logout using a UIWebView in a ModalViewController please?
I also wish to know how can I create an "instagram" instance in another class, which I use as my AppDirector class, rather than having to do it in the app delegate.
(The AppDirector class is my initial view controller, which is also the rootViewController of my side menu system).
I have tried my best to edit the codes myself but I kept failing. Can I get some help? Thanks so much in advance for this library and your help!
hello can you give some note to how it's implemented in app
Hello Crino,
How can I POST the following using your sdk
POST/users/user-id/relationship
Thank you
Cem Kacmaz
A while back I had setup "http://ig" + "clientId" + "://authorize" as a redirect URI in Instagram client manager. I needed to add a sandbox invite to the client but it was throwing an error "Submit a valid website" and highlighting the Redirect URI field as red. I removed it to be able to add the invite but I now cannot add it back in.
I have tried numerous variations
http://ige1716724820542e9a39ec32654785ab8://authorize
http://ige1716724820542e9a39ec32654785ab8
I continue to receive the submission error.
i'm trying to implement your example in my own project. obviously before i make a request, i do login. anyway this is my header file:
@interface InstagramPhotos : BasciPhotoDictionary
and this is my implementation file:
@implementation InstagramPhotos
-(void)requestForPhoto
{
SocialMapAppDelegate* appDelegate = (SocialMapAppDelegate*)[UIApplication sharedApplication].delegate;
// here i can set accessToken received on previous login if there is
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"users/self/followed-by", @"method", nil];
[appDelegate.instagram requestWithParams:params
delegate:self];
}
}
the problem is that the delegate methods are never called. what is wrong?
thank you
I am attempting to consume and then print out an Instagram photo caption that contains emoji. The caption text returned in the dictionary looks like the following
text = "Sample comment. \Uf4f1";
I attempt to set an NSString equal to this value with the following line
NSString *caption = [NSString stringWithUTF8String:[[[igPhotoDict objectForKey:@"caption"] objectForKey:@"text"] UTF8String]]
The NSString then contains the following:
Sample comment.
What is the proper way to handle this string containing unicode emoji characters?
Hi,
I want to post messages from my app to Instagram. Can anyone help me on this.
Thanks,
Nandini
I’ve recently added instagram-ios-sdk to the CocoaPods package manager repo.
CocoaPods is a tool for managing dependencies for OSX and iOS Xcode projects and provides a central repository for iOS/OSX libraries. This makes adding libraries to a project and updating them extremely easy and it will help users to resolve dependencies of the libraries they use.
However, instagram-ios-sdk doesn't have any version tags. I’ve added the current HEAD as version 0.0.1, but a version tag will make dependency resolution much easier.
In case you didn’t know this yet; you can tag the current HEAD as, for instance, version 1.0.0, like so:
$ git tag -a 1.0.0 -m "Tag release 1.0.0"
$ git push --tags
Hi
How to logout not just inside the application, how to login with a new user because it always return to the first login
I think we must clear cookies from Safari
Thanks
I was very confused after going through the example project added to the repo. Would going through Facebook-iOS-SDK help me understand the flow better?
The two delegates do not work together in the same UIViewController, just call IGSessionDelegate
In my project don't work IGRequestDelegate.
In AppDelegate: self.instagram = [[Instagram alloc] initWithClientId:CLIENT_ID
delegate:nil];
Authorization is ok, but when I'm using:
AppDelegate* appDelegate = (AppDelegate_)[UIApplication sharedApplication].delegate;
appDelegate.instagram.accessToken = [[NSUserDefaults standardUserDefaults] objectForKey:@"instagramAccessToken"];
NSMutableDictionary_ params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"users/self/feed", @"method", nil];
[appDelegate.instagram requestWithParams:params
delegate:self];
In console i get next answer:
URL: https://api.instagram.com/v1/users/self/feed?access_token=ACCESS_TOKEN
IGRequestDelegate use with
And it does not result.
Sorry this might be a stupid question but I just started using Instagram SDK... I opened the example project and just wondered if theres a follow method declared anywhere in this project.
Can someone please explain me how to access the "follow user" method? Please help me I'm new at Instagram SDK :$ :)
Hi Crino,
I stuck in very strange problem. I am constantly getting error "Redirect URI does not match registered redirect URI".
I have set Redirect URI as : "https://igfdabfbdacdd14f908a456195445a7e38://authorize"
Set URL Schema in .plist file as : "igfdabfbdacdd14f908a456195445a7e38://authorize"
And when i try to login i get URL like : "https://instagram.com/oauth/authorize?response_type=token&redirect_uri=igfdabfbdacdd14f908a456195445a7e38%3A%2F%2Fauthorize&scope=comments+likes&client_id=fdabfbdacdd14f908a456195445a7e38"
Can you help me out what i am doing wrong?
Any help is appreciated.
Thank you.
So I could either get the ids of the images the user has liked and compare with a particular image, or I could get the ids of the users who have liked a particular image and compare. However I'm curious as to whether there is an integrated method, or whether I'll have to do one of the methods stated above?
Hi there! awesome SDK but am generating this URL and so far i only get this answer from instagram:
my Url generated in the app: https://instagram.com/oauth/authorize?response_type=token&redirect_uri=248796138fde415ca17f4f3f7d59d43b%3A%2F%2Fauthorize&scope=basic&client_id=248796138fde415ca17f4f3f7d59d43b
the response:
{"code": 400, "error_type": "OAuthException", "error_message": "Redirect URI does not match registered redirect URI"}
any help would be very appreciated!
Regards,
Jorge.
When adding sdk project as static library, it wob't compile, because there is no instagram-ios-sdk-Prefix.pch file present (or I can't find it), You just need to remove the pch reference from the project and remove it from the build settings... I hope it should be clear to you what the problem is, but let me know if you need more details to fix it, or want me to send a pull request :) 👍
How can I get the count of all the followers of a user?
Hi @crino ,
Could you explain what is the difference between
requestWithParams:delegate:
and
requestWithMethodName:params:httpMethod:delegate:
and an example of situations where one will be preferred over the other?
Many thanks!
Can't I use custom redirect url?
Apple now requires that auth happen within app. Kicking out to Safari will get you rejected. :-(
Hey Crino,
I want to thank you by the API, it is great!!
But I have a problem with logout feature, I don't know if it's a bug or a question...
When I call logout, the API invalidate the access token in the application's scope, it works great, but the login still alive in the safari's scope... so, if I want to login with other different user, I can't. How can I do that?
Seems that facebook API has the same issue: http://stackoverflow.com/questions/6226950/facebook-ios-sdk-logout-question
But there is a work around to avoid this: https://github.com/facebook/facebook-ios-sdk/pull/242/files
I have tried to find out how to do this in your API, but still nothing...
Can you help me?
(sorry my english!)
How can I cancel a request when using Instagram sdk?
If I need send 2, 3 or more request from same ViewController, how I can do this? And how I can distinguish different data result in "request:(IGRequest *)request didLoad:(id)result"?
Hey,
How can I get the username? I didn't find the point where I can get the "username" value... I just have the valid access token, but seems that they send the username at the response package... Look at the response format when we have authentication:
"If successful, this call will return a neatly packaged OAuth Token that you can use to make authenticated calls to the API. We also include the user who just authenticated for your convenience:"
{
"access_token": "fb2e77d.47a0479900504cb3ab4a1f626d174d2d",
"user": {
"id": "1574083",
"username": "snoopdogg",
"full_name": "Snoop Dogg",
"profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_1574083_75sq_1295469061.jpg"
}
}
Could you help me?
Thanks!
Hi, Cristiano! First of all, thank you for the great library! :) 👍
I've faced the problem: session is invalidated (token is set to nil) on any error, even if there's just no Internet connection.
I'm not sure if this is an issue with library - may be the best practice is to handle such errors outside, but I've got a workaround at the moment: https://github.com/rudyryk/instagram-ios-sdk/commit/d9ca9f2ff3d2131a24c6fe8c1772794f9f63ddd8
Session is invalidated only when we get @"OAuthAccessTokenException"
error.
What do you think?
i experienced a problem with my app.. it experienced a heavy load of user at the same time (about 4000) and then instagram shut down my api... then... i had to submit a new version of the app to the app store and to wait a whole week for apple to authorised it... is there any way to control the url from the code so i can change it from my service if something like that happens again?
thank you very much!
I have use multi scope
code :
[appDelegate.instagram authorize:[[NSArray alloc] initWithObjects:@"comment",@"likes", nil ] ];
When I touch login button I got error message from instagram.com.
I think URL generate from iOS it's incorrect.
URL :
scope=comments%2Blikes
And I edit %2B to "+" It's worked.
URL :
scope=comments+likes
Hi,
Thank you very much for this v ery useful sdk it's very kind from u. you're doing a great job by facilitating instagram integration. the sdk works fine for me but sometimes when i logout and the login safari shows an alert like "safari cannot open this page invalid adress" i'm trying to figure out why ... do you have an idea ? thx
I have create an app on instagram. have set redirect URI as following:
https://igCLIENT_ID://authorize
In my iPhone project's info.plist, am giving igCLIENT_ID:// in URL SCHEME. but am getting the same error again and again on login. it takes user name, password and then shows this error.
I need to add instagram to my project asap. Any help will be much appreciated.
Thank you
Hi Crino,
First of all: great work mate!
Thanks ;-).
And then a little question:
Do you think it's possible to use the Instagram Real-time API with this SDK? (http://instagram.com/developer/realtime/)
Would it be possible to respond to the GET/POST- requests Instagram will send, right from within an iOS app?
Kind regards,
wuotr
Hello,
Dear I did this one:
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"users/self/feed", @"method", nil];
but how to get the data of locations ?
an example:
cell.textLabel.text = [[self.data objectAtIndex:indexPath.row] objectForKey:@"location->id"];
^ I want to return the id of location
Thanks alot
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.