0
我正尝试在iPad应用程序的Facebook墙上发布图片。但是没有任何事情发生,Facebook网站弹出来允许它,但图像从未发布。这是我的代码:在Facebook墙上发布图片
-(IBAction)facebookButton {
facebook = [[Facebook alloc] initWithAppId: APP_ID andDelegate:self];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) {
facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}
if (![facebook isSessionValid]) {
[facebook authorize:nil];
}
[facebook authorize:[NSArray arrayWithObjects: @"publish_stream",@"user_photos", nil]];
UIImage* image = [UIImage imageNamed: @"image.png"];
NSData* imgData = UIImagePNGRepresentation(image);
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Hey", @"message", //whatever message goes here
imgData, @"data", //img is your UIImage
nil];
[facebook requestWithGraphPath:@"me/photos"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
}
谢谢!这与[this](http://stackoverflow.com/questions/5783782/fbdidlogin-not-called-ios#answer-6138046)结合起来了! – Labbekak 2012-07-20 13:14:10