2011-10-26 13 views
0

カスタム関数でレスポンスを取得する方法は?Facebook-iOs-APIカスタム関数でレスポンスを取得する方法

- (void)request:(FBRequest *) request didReceiveResponse:(NSURLResponse *)response{ 
NSLog(@"I have some information"); 
// [wait stopAnimating]; 
    //wait.hidden; 
} 

    - (void)request:(FBRequest *) request didLoad:(id)result{ 
    if ([result isKindOfClass:[NSArray class]]){ 
      result = [result objectAtIndex:0]; 
    } 
    else{ 
     // dictionaryWithNames = result; 
     infoStatus.text = [result objectForKey:@"name"]; 
    infiId.text = [result objectForKey:@"id"]; 
} 
if ([result objectForKey:@"data"]){ 
    arrayWithFriends = [result objectForKey:@"data"]; 
    if (arrayWithFriends != nil) { 
    for (NSDictionary *output in arrayWithFriends){ 
     NSString *namaFriends = [output objectForKey:@"name"]; 
     NSLog(@"Your Friend %@", namaFriends); 
     infoStatus.text = @"If you could see konsole... You can't"; 
     continue; 
     } 
    } else { 
     infoStatus.text = @"You Haven't Got friends or Mutuals"; 
    } 
} 

}

しかし、私は別の機能を持っている必要があり、そのことは不可能(またはあまりにもハード)私は、この機能にわずか数パターンを使用して、必要なすべての応答を取得するには:基本的には答えが取得します。

答えて

0

あなたは、彼らがcurrentAPIcall変数を作成し、そのような要求に応じて、それを埋める

https://github.com/facebook/wishlist-mobile-sample/blob/master/iOS/Wishlist/Wishlist/HomeViewController.m

ここではそのサンプル・アプリケーションでFacebookの開発者と同じスキーマを使用することができます。

/** 
* Make a Graph API Call to get information about the current logged in user. 
*/ 
- (void) apiFQLIMe { 

    currentAPICall = kAPIFQLMe; 
    // Using the "pic" picture since this currently has a maximum width of 100 pixels 

    // and since the minimum profile picture size is 180 pixels wide we should be able 
    // to get a 100 pixel wide version of the profile picture 

    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 

            @"SELECT uid, name, pic FROM user WHERE uid=me()", @"query", 

            nil]; 
    [facebook requestWithMethodName:@"fql.query" 

            andParams:params 
           andHttpMethod:@"POST" 

            andDelegate:self]; 
} 




- (void)request:(FBRequest *)request didLoad:(id)result { 
    [self hideActivityIndicator]; 
    if ([result isKindOfClass:[NSArray class]]) { 
     result = [result objectAtIndex:0]; 
    } 
    switch (currentAPICall) { 
     case kAPIFQLMe: 
     { 
      // This callback can be a result of getting the user's basic 
      // information or getting the user's permissions. 
      if ([result objectForKey:@"name"]) { 
       // If basic information callback, set the UI objects to 
       // display this. 
       self.profileNameLabel.text = [result objectForKey:@"name"]; 
       // Get the pr 

...

関連する問題