Instagram API に取り組むのはこれが初めてです。ユーザーのデバイスに既に instagram アプリがある場合、アプリケーションからユーザーの詳細を取得するにはどうすればよいでしょうか?
ログインしたiPhoneにinstagramアプリがありますが、現在、アプリはサファリにリダイレクトされ、そこでinstagramの資格情報を要求しています。
誰でもこれで私を助けてもらえますか?
Instagram API に取り組むのはこれが初めてです。ユーザーのデバイスに既に instagram アプリがある場合、アプリケーションからユーザーの詳細を取得するにはどうすればよいでしょうか?
ログインしたiPhoneにinstagramアプリがありますが、現在、アプリはサファリにリダイレクトされ、そこでinstagramの資格情報を要求しています。
誰でもこれで私を助けてもらえますか?
Instagram ユーザーの詳細を取得するためにファイルする必要がInstagram.h
あります。Instagram.m
アプリ ID を取得するには、Instagram 開発者サイトでアプリケーションを作成する必要があります。
instagram = [[Instagram alloc] initWithClientId:APP_ID delegate:nil];
NSString *const instagramUrlScheme = @"---YourAppName---";
-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { //openo
if ([urlStr hasPrefix:instagramUrlScheme]) {
//[self showAlertWithTitle:THIS_METHOD message:url.description];
return [self.instagram handleOpenURL:url];
}
}
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
NSString *urlStr = url.description;
if ([urlStr hasPrefix:instagramUrlScheme]) {
return [self.instagram handleOpenURL:url];
}
return NO;
}
これらは、実装する必要がある instagram デリゲートです。
#pragma - IGSessionDelegate
-(void)igDidLogin
{
NSLog(@"Instagram did login");
//[[self appDelegate] showAlertWithTitle:@"igDidLogin" message:@""];
// here i can store accessToken
[[NSUserDefaults standardUserDefaults] setObject:[self appDelegate].instagram.accessToken forKey:@"accessToken"];
[[NSUserDefaults standardUserDefaults] synchronize];
//NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"users/self/followed-by", @"method", nil];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"users/self", @"method", nil];
[[self appDelegate].instagram requestWithParams:params
delegate:self];
}
-(void)igDidNotLogin:(BOOL)cancelled
{
NSLog(@"Instagram did not login");
NSString* message = nil;
if (cancelled) {
message = @"Access cancelled!";
}
else {
message = @"Access denied!";
}
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:message
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
}
-(void)igDidLogout
{
NSLog(@"Instagram did logout");
// remove the accessToken
[[NSUserDefaults standardUserDefaults] setObject:nil forKey:@"accessToken"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
-(void)igSessionInvalidated
{
NSLog(@"Instagram session was invalidated");
}
Instagramに接続したい場合は、これらを使用する必要があります。
[self appDelegate].instagram.accessToken = [[NSUserDefaults standardUserDefaults] objectForKey:@"accessToken"];
[self appDelegate].instagram.sessionDelegate = self;
[[self appDelegate].instagram logout];
[[self appDelegate].instagram authorize:[NSArray arrayWithObjects:@"comments", @"likes", nil]];
お役に立てれば:
私も知っている限り、これは不可能です。
アプリから他のアプリの詳細を取得できません。
この instagram 開発者リンクで instagram の詳細情報を取得できます。
これがお役に立てば幸いです。
アプリから他のアプリにリダイレクトするとき、私の知る限り、他のアプリの詳細 (ログインの詳細) にアクセスできません。