简体   繁体   中英

Facebook API: Post on friend wall

是否可以在用户的​​朋友墙上发布一些东西而不必先获取所有朋友(因此您可以获取朋友ID)?

[facebook requestWithGraphPath:@"me/friends" andDelegate:self];  

You can get the friends of the logged in user by issuing a request to me/friends .
Then you can create a ui element that shows the list of friends and the user can select the ones he want to share with.

Then, after the user selected you simply post on their walls by issuing a POST to FRIEND_ID/feed ( Feed connection of the User object ).
You'll need to have the publish_stream permissions which lets you: Enables your app to post content, comments, and likes to a user's stream and to the streams of the user's friends (http://developers.facebook.com/docs/authentication/permissions/)

See this

-(IBAction)PostToBuddyWall
{

NSMutableDictionary  *postVariablesDictionary = [[NSMutableDictionary alloc] init];


[postVariablesDictionary setObject:@"LOL" forKey:@"name"];    
[postVariablesDictionary setObject:self.postTextView.text forKey:@"message"];


[objDelegate.facebook requestWithGraphPath:[NSString stringWithFormat:@"%@/feed",friendId] andParams:postVariablesDictionary andHttpMethod:@"POST" andDelegate:nil];

NSLog(@"message: %@",postVariablesDictionary);
[postVariablesDictionary release];

UIAlertView *facebookAlter=[[UIAlertView alloc] initWithTitle:@"Message" message:@"Posted successfully on facebook" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil, nil];
[facebookAlter show];
[facebookAlter release]; 

[self dismissModalViewControllerAnimated:YES];    
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM