1

我正在尝试使用他们的 SDK 从 Facebook 请求数据,但我一直一无所获......

我的 .h 文件...

#import <UIKit/UIKit.h>
#import "Facebook.h"

@interface VPSettingsViewController : UIViewController <FBRequestDelegate, FBDialogDelegate, FBSessionDelegate> {
    Facebook *facebook;

    NSArray *items;
}

@end

下面是我的 .m 文件,它基本上调用了一个请求,并且当我从 Facebook 收到请求时应该做一些事情,但是 *(void)request:(FBRequest )request didLoad:(id)result永远不会被调用...

    - (void)viewDidLoad
{
    [super viewDidLoad];

    facebook = [[Facebook alloc] initWithAppId:@"333593533397126" andDelegate:self];

    [facebook requestWithGraphPath:@"me/friends" andDelegate:self];
    // Do any additional setup after loading the view.
}

- (void)request:(FBRequest *)request didLoad:(id)result {
    NSLog(@"Inside didLoad");
    if ([result isKindOfClass:[NSArray class]]) {
        result = [result objectAtIndex:0];
    }
    // When we ask for user infor this will happen.
    if ([result isKindOfClass:[NSDictionary class]]){
        //NSDictionary *hash = result;
        NSLog(@"Birthday: %@", [result objectForKey:@"birthday"]);
        NSLog(@"Name: %@", [result objectForKey:@"name"]); 
    }
    if ([result isKindOfClass:[NSData class]])
    {
        NSLog(@"Profile Picture");
        //[profilePicture release];
        //profilePicture = [[UIImage alloc] initWithData: result];
    }
    NSLog(@"request returns %@",result);
    //if ([result objectForKey:@"owner"]) {}

};

不是我得到任何错误,只是我从来没有进入过负载......没有什么是 NSLOGing

我也在我的 iPhone 上登录了 Facebook ......

4

1 回答 1

0

这是因为您的请求不会成功。尝试实现以下委托以了解失败背后的原因:

 - (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response;
 - (void)request:(FBRequest *)request didFailWithError:(NSError *)error;

还要确保你的类符合协议FBRequestDelegate

于 2012-07-20T23:37:08.003 回答