如何在Facebook iOS SDK 3.1中发布给朋友的墙? [英] How to post to a friend's wall in facebook iOS SDK 3.1?
问题描述
我的SDK 3.1适用于iOS 6发布状态更新,并且拥有我想在其墙上张贴的人的脸书用户ID。我只是想让它说嗨。到一个人的墙上。
我可以使用/ [id] / feed来定位他们的Feed,但是我必须提供一个图形对象?如果我使用startForPostWithGraphPath()。
我想到了!
首先当然要在这里实现FBFriendPickerDelegate,除非你已经有了他们的朋友ID了。 http://developers.facebook.com/ docs / howtos / filter-devices-friend-selector-using-ios-sdk /
然后重要的部分,如何发布到朋友的墙上: / p>
- (void)facebookViewControllerDoneWasPressed:(id)sender
{
NSString * fid;
NSString * fbUserName;
//从选择中获取Facebook朋友的ID。刚刚获得1。
for(id< FBGraphUser> user在friendPickerController.selection中)
{
NSLog(@\\\
user =%@ \,user);
fid = user.id;
fbUserName = user.name;
}
//发帖。
NSMutableDictionary * params = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@Join me!,@message,@http://itunes.apple.com/my-super-app,@link ,@我的超级应用,@name,nil];
NSLog(@\\\
params =%@ \\\
,params);
//发贴到朋友的墙上
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@%@ / feed,fid]参数:params HTTPMethod:@POST
completionHandler:^(FBRequestConnection * connection,id result,NSError * error)
{
//告诉用户它有效。
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@Shared
message:[NSString stringWithFormat:@Invited%@!error =%@,fbUserName,error]
delegate :nil
cancelButtonTitle:@OK
otherButtonTitles:nil];
[alertView show];
}
];
//关闭好友选择器。
[self dismissModalViewControllerAnimated:YES];
}
I have the SDK 3.1 working for iOS 6 for posting status updates and I have the facebook user id of the person who I want to post on their wall.
I just want it to say "hi." to just one person's wall. I can target their feed with "/[id]/feed" but then I have to supply a graph object? if I use startForPostWithGraphPath() anyways.
I figured it out!
First of course implement FBFriendPickerDelegate per here, unless you already have their friend ID somehow. http://developers.facebook.com/docs/howtos/filter-devices-friend-selector-using-ios-sdk/
Then the important part, how to post to friend's wall:
- (void)facebookViewControllerDoneWasPressed:(id)sender
{
NSString* fid;
NSString* fbUserName;
// get facebook friend's ID from selection. just gets 1 right now.
for (id<FBGraphUser> user in friendPickerController.selection)
{
NSLog(@"\nuser=%@\n", user);
fid = user.id;
fbUserName = user.name;
}
//Make the post.
NSMutableDictionary* params = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Join me!", @"message", @"http://itunes.apple.com/my-super-app", @"link", @"My Super App", @"name", nil];
NSLog(@"\nparams=%@\n", params);
//Post to friend's wall.
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/feed", fid] parameters:params HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
//Tell the user that it worked.
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Shared"
message:[NSString stringWithFormat:@"Invited %@! error=%@", fbUserName, error]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
];
//Close the friend picker.
[self dismissModalViewControllerAnimated:YES];
}
这篇关于如何在Facebook iOS SDK 3.1中发布给朋友的墙?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!