1

Instagram API に取り組むのはこれが初めてです。ユーザーのデバイスに既に instagram アプリがある場合、アプリケーションからユーザーの詳細を取得するにはどうすればよいでしょうか?

ログインしたiPhoneにinstagramアプリがありますが、現在、アプリはサファリにリダイレクトされ、そこでinstagramの資格情報を要求しています。

誰でもこれで私を助けてもらえますか?

4

3 に答える 3

1

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]];

お役に立てれば:

于 2014-03-07T13:27:40.143 に答える
0

私も知っている限り、これは不可能です。

アプリから他のアプリの詳細を取得できません。

この instagram 開発者リンクで instagram の詳細情報を取得できます。

これがお役に立てば幸いです。

于 2013-09-19T10:25:34.107 に答える
0

アプリから他のアプリにリダイレクトするとき、私の知る限り、他のアプリの詳細 (ログインの詳細) にアクセスできません。

于 2013-09-19T10:18:09.470 に答える