Reputation: 51
How to post message on Facebook friend's wall using NEWFacebook SDK selecting target_id of friend.
Upvotes: 2
Views: 1574
Reputation: 1558
check delegate methodes
-(void)fbDidLogin { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"]; [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"]; [defaults synchronize]; [facebook requestWithGraphPath:@"me/picture" andDelegate:self]; NSLog(@"Login Success with :%@ %@",facebook.accessToken,facebook.expirationDate); } -(void)fbDidLogout { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) { [defaults removeObjectForKey:@"FBAccessTokenKey"]; [defaults removeObjectForKey:@"FBExpirationDateKey"]; [defaults synchronize]; } NSLog(@"Logout Success"); } -(void)request:(FBRequest *)request didLoad:(id)result { if(c==0) { NSData *data = [NSData dataWithData:(NSData*)result]; UIImage *profilePic = [[[UIImage alloc] initWithData:data] autorelease]; image1.image=profilePic; [self postWall]; // NSLog(@"response is %@", result); // NSString *email =[result objectForKey:@"name"]; // NSString *userFbId =[result objectForKey:@"id"]; // NSLog(@"%@",email); // NSLog(@"%@",userFbId); c=1; } else { NSLog(@"%@",result); NSLog(@"posted!!") ; } } -(void)request:(FBRequest *)request didFailWithError:(NSError *)error { NSLog(@"Failed with error: %@", [error localizedDescription]); }
Upvotes: 0
Reputation: 1558
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"https://developers.facebook.com/docs/reference/dialogs/",@"link", @"Facebook Dialogs",@"name", @"Reference Documentation",@"caption", @"Using Dialogs to interact with users.",@"description", @"Facebook Dialogs are so easy!",@"message", nil]; // [facebook requestWithGraphPath:@"me/feed" andParams:params andDelegate:self]; //[facebook requestWithMethodName:@"me/feed" andParams:params andHttpMethod:@"POST" andDelegate:self]; [facebook requestWithGraphPath:@"me/feed" andParams:params andHttpMethod:@"POST" andDelegate:self];
Upvotes: 0
Reputation: 3733
NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:4];
[variables setObject:[NSString stringWithFormat:@"Hi."] forKey:@"message"];
[variables setObject:@"http://icon.png" forKey:@"picture"]; //http://tinyurl.com/45xy4kw
[variables setObject:@"Create post" forKey:@"name"];
[variables setObject:@"Write description." forKey:@"description"];
[_facebook requestWithGraphPath:[NSString stringWithFormat:@"/%@/feed",facebook_user_id]
andParams:variables
andHttpMethod:@"POST"
andDelegate:self];
Upvotes: 5