나를 위해 완벽하게 작동하는이 코드를 사용해보십시오.
-(void)buttonPressed:(id)sender{
facebook = [[Facebook alloc] initWithAppId:@"YOUR_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];
}else{
[self postWall];
}
// Pre 4.2 support
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [facebook handleOpenURL:url];
}
- (void)fbDidLogin {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];
[self postWall];
}
-(void)postWall{
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"https://developers.facebook.com/docs/reference/dialogs/",@"link",
@"http://fbrell.com/f8.jpg",@"picture",
@"Facebook Dialogs",@"name",
@"Reference Documentation",@"caption",
@"Using Dialogs to interact with users.",@"description",
@"Facebook Dialogs are so easy!",@"message",
nil];
[[self facebook] dialog:@"feed" andParams:params andDelegate:self];
}
는
에게 앱 ID를 추가하는 것을 잊지 마십시오.
일부 코드를 게시 할 수 있습니까 ?? –
한번 쯤은 문제를 경험했습니다. 코드를 작성하면 반드시 도와 드리겠습니다. –