0

我想通过使用后备共享在 facebook 上发布提要。它应该包含图像和消息。我通过更改参数尝试了很多

 NSMutableDictionary *postParams =
[[NSMutableDictionary alloc] initWithObjectsAndKeys:
 @"http://www.abc.com",@"link",
 self.produtObj.productImageURL, @"picture",
 self.produtObj.productName, @"name",
 self.produtObj.productDescription, @"message",
 nil];

[FBRequestConnection
 startWithGraphPath:@"me/feed"
 parameters:postParams
 HTTPMethod:@"POST"
 completionHandler:^(FBRequestConnection *connection,
                     id result,
                     NSError *error) {
     NSString *alertText;
     if (error) {
         alertText = [NSString stringWithFormat:
                      @"error: domain = %@, code = %d",
                      error.domain, error.code];
     } else {
         alertText = [NSString stringWithFormat:
                      @"Posted action, id: %@",
                      [result objectForKey:@"id"]];
     }
     // Show the result in an alert
     [[[UIAlertView alloc] initWithTitle:@"Result"
                                 message:alertText
                                delegate:self
                       cancelButtonTitle:@"OK!"
                       otherButtonTitles:nil]
      show];
 }];

使用此代码,提要显示在一个框中,单击它会将我带到指定的链接。我只想在盒子里有一个带有故事的图像缩略图。请帮我。这是我在 SOF 的第一个问题。所以请原谅我的错误。提前致谢。:)

4

1 回答 1

1

我真的更喜欢使用 UIActivityItemViewConroller 将内容推送到 facebook。

用户需要在其设备上登录 facebook。您可以通过 Facebook 部分中的设置来做到这一点。

我为我的东西制作了这样的新控制器:

    NSMutableArray *stuff = [[NSMutableArray alloc]init];
    NSString *textstring = @"Now is the time for all good men to come to the aid of their country. Lorum Ipsum etc";
    UIImage *pic = [UIImage imageNamed:@"Icon-Small-50"];//A local image
    NSString *URL = @"http://nwc.co/images/nwc-icon-200.gif";//A link to an image
    [stuff addObject:textstring];
    [stuff addObject:pic];
    [stuff addObject:URL];
    UIActivityViewController *vc = [[UIActivityViewController alloc]initWithActivityItems:stuff applicationActivities:nil];

    [self.navigationController presentViewController:vc animated:YES completion:^{
        //do something here when they are done   
    }];

如果您运行上述程序,您会注意到文本、本地图像和指向在线图像的链接都出现在帖子上。如果您不想在活动图标弹出时混淆人们,您可以排除其他活动:

vc.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypePostToTwitter, UIActivityTypePostToWeibo, UIActivityTypeMail, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll];
于 2013-04-20T05:29:30.740 回答