当我通过fbconnect在Facebook上发布图像时,如何隐藏图像的网址?

时间:2012-11-05 10:08:09

标签: iphone facebook ios5

我正在使用此代码在facebook上发布图片,但它也在facebook上显示图片网址。我想隐藏这个网址:

这是我将图片发布到Facebook的代码

#pragma mark Facebook 

-(void)facebook
{
    AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
        @"I'm using Shape App", @"message",  @"I'm using Shape App", @"caption",
        @"http://www.imageurlhost.com/images/3kft472rvl2qtnzx11_Sample.png", @"picture",
        @"I'm using Shape App", @"title",nil];
    [[delegate facebook] dialog:@"feed" andParams:params andDelegate:self];
  }

请查看下面的图片

enter image description here

2 个答案:

答案 0 :(得分:1)

您正在做的是发布一个网址,因此它显示为:您共享的链接。这个链接确实指向图像而不是网站并不重要。

您可以选择更改

a)发布指向Open Graph页面的链接,其中包含图像 - 然后您可以设置将显示该共享链接的标题和说明,或

b)将其张贴为真实照片,https://developers.facebook.com/docs/reference/api/user/#photos

答案 1 :(得分:1)

我已通过最新的ios6 facebook集成解决: 为此,您必须在将此代码放入要调用Facebook的方法之后导入Social.framework。但它仅适用于iOS 6及更高版本

       NSData *imageData=[NSData dataWithContentsOfURL:[NSURL urlWithString:@"http://www.imageurlhost.com/images/3kft472rvl2qtnzx11_Sample.png"]];
 if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])

   {
    mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
    [mySLComposerSheet setInitialText:[NSString stringWithFormat:@"I am using Shape App"]];
    [mySLComposerSheet addImage:[UIImage imageWithData:imageData]];
    [self presentViewController:mySLComposerSheet animated:YES completion:nil];
   }

  else

   {
    UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"No Facebook Account" message:@"There are no Facebook accounts configured.You can add or create a Facebook account in Settings" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
    [alertView show];
}
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result)
 {
   // NSLog(@"dfsdf");

    switch (result) {
        case SLComposeViewControllerResultCancelled:

            break;
        case SLComposeViewControllerResultDone:

            break;
        default:
            break;
    }

}];