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