问题描述
场景: 我想将帖子分享到只有选定的朋友的墙上。
先决条件:
在FB朋友的整个列表中,只选择必要的朋友并创建一个数组
尝试的步骤:
强制>使用 FBWebDialogs
并调用方法 +(void)presentFeedDialogModallyWithSession:(FBSession *)会话参数:(NSDictionary *)参数处理程序:(FBWebDialogHandler)处理程序;
在参数字典中,设置to的值。
收件人只有一个,工作完全正常。
试用版2: 使用 FBDialogs
并调用 +(FBAppCall *)presentShareDialogWithParams:(FBShareDialogParams *)params clientState:(NSDictionary *)clientState处理程序:(FBDialogAppCallCompletionHandler)handler;
p>
在 FBShareDialogParams
中,设置好友数组。
工程正常。但只有在安装了Facebook应用程序时才可以使用。其他没有工作。
...
有些可以帮我解决这个问题:
- 分享到多个朋友的墙上。
- 应该使用或不使用
Facebook应用程序安装在手机上。
谢谢
您必须执行以下操作:
FBShareDialogParams * p = [[FBShareDialogParams alloc] init];
p.friends = friendIdsArray;`
p.link = url;
//检查FB应用程序是否安装并可以使用此方法
if([FBDialogs canPresentShareDialogWithParams:p]){
[FBDialogs presentShareDialogWithParams:p
clientState :nil
处理程序:^(FBAppCall *调用,
NSDictionary *结果,
NSError *错误){
//做一些错误检查
}
//回退到本质上是一个webview
else {
//逗号分隔的Facebook的IDs
NSDictionary * params = [NSDictionary dictionaryWithObjectsAndKeys:@1234,5678,@to ,nil];
NSString * message = @我喜欢Objective-C;
[FBWebDialogs presentRequestsDialogModallyWithSession:[FBSession activeSession]
消息:消息
标题:nil
参数:params
处理程序:^(FBWebDialogResult结果,
NSURL * resultURL,NSError * error){
//做一些错误检查
}
这是我使用的,我发现唯一的问题是,发送请求时可以包含的Facebook ID数量似乎有一些未知的限制。它有所不同,取决于我找不到文件的因素。我认为FB正试图阻止人们滥用/滥用垃圾邮件,理由很好....
Scenario: I would want to share the post to the wall of only selected friends.
Prerequisites followed:Out of the entire list of FB Friends, select only the necessary friends and create an Array
Steps Tried:
Trial 1: Use FBWebDialogs
and call method + (void)presentFeedDialogModallyWithSession:(FBSession *)session parameters:(NSDictionary *)parameters handler:(FBWebDialogHandler)handler;
In the Parameters dictionary, set value for "to".
Works perfectly fine when the recipient is only one. Cannot share if the recipient is more than one.
Trial 2: Use FBDialogs
and call + (FBAppCall *)presentShareDialogWithParams:(FBShareDialogParams *)params clientState:(NSDictionary *)clientState handler:(FBDialogAppCallCompletionHandler)handler;
In the FBShareDialogParams
, set the Array of Friends.works fine. But works only when the Facebook App is installed. Else doesnt work.
...
Can some please help me solve this problem:
- Share on wall of multiple Friends.
- Should work with or without theFacebook App being installed on phone.
Thanks
You must do something like:
FBShareDialogParams *p = [[FBShareDialogParams alloc] init];
p.friends = friendIdsArray;`
p.link = url;
//check if the FB app is installed and can use this method
if ([FBDialogs canPresentShareDialogWithParams:p]) {
[FBDialogs presentShareDialogWithParams:p
clientState:nil
handler:^(FBAppCall *call,
NSDictionary *results,
NSError *error) {
//do some error checking
}
// fallback to what is essentially a webview
else {
// string of comma separated Facebook Ids
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:@"1234,5678", @"to", nil];
NSString *message = @"I love Objective-C";
[FBWebDialogs presentRequestsDialogModallyWithSession:[FBSession activeSession]
message:message
title:nil
parameters:params
handler:^(FBWebDialogResult result,
NSURL *resultURL, NSError *error) {
// do some error checking
}
This is what I use, the only problem I'm finding is that there appears to be some unknown limit to the number of Facebook Ids you can include when sending out a request. It varies and depends on factors I can't find documented. I think FB is trying to keep people from abusing/spamming people, for good reason....
这篇关于iOS:发布在所选FB朋友的墙上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!