我有一些代码可以进行大量设置,然后使用 FB-connect 发布到 Facebook。有一次,我有这样的事情:
NSString *description =
@"Wow, what a great app! "
@"Download it free: "
@"<a href=\"http://itunes.apple.com/us/app/myApp/id12345?mt=8\">"
@"On iTunes AppStore."
@"</a>"
;
// post FB dialog
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
// @"This is what I say about myApp:", @"message", // user msg
@"MyApp!", @"name", // Bold/blue name
@"MyApp is cool!", @"caption", // 1st line
description, @"description", // 2nd line
@"http://itunes.apple.com/us/app/myApp/id12345?mt=8", @"link",
@"http://farm6.static.flickr.com/5230/5576336654_075c2abcf9_s.jpg", @"picture",
nil];
[facebook dialog: @"feed"
andParams: params
andDelegate: self];
它几乎有效!唯一的问题是:在我的描述字符串中,“<a href...
”和“</a>
”之间的所有内容都没有显示在我的 Facebook 墙上。
所以问题是:如何在我的帖子中添加链接( anchor 标记样式)?
最佳答案
无法在描述中添加链接,但是您可以使用“属性”和“操作”键获得相同的结果,如下所述:
Facebook API Feed Dialog Documentation
代码如下:
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary *propertyvalue = [NSDictionary dictionaryWithObjectsAndKeys:@"On iTunes AppStore", @"text", @"http://itunes.apple.com/us/app/myApp/id12345?mt=8", @"href", nil];
NSDictionary *properties = [NSDictionary dictionaryWithObjectsAndKeys:propertyvalue, @"Download it free:", nil];
NSDictionary *actions = [NSDictionary dictionaryWithObjectsAndKeys:@"Download it free", @"name",@"http://itunes.apple.com/us/app/myApp/id12345?mt=8", @"link", nil];
NSString *finalproperties = [jsonWriter stringWithObject:properties];
NSString *finalactions = [jsonWriter stringWithObject:actions];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
userfbid, @"to",
@"http://itunes.apple.com/us/app/myApp/id12345?mt=8", @"link",
@"http://farm6.static.flickr.com/5230/5576336654_075c2abcf9_s.jpg", @"picture",
@"Name name name", @"name",
@"Caption caption caption", @"caption",
@"Description description description", @"description",
finalproperties, @"properties",
finalactions, @"actions",
nil];
[_facebook dialog:@"feed" andParams:params andDelegate:self];
属性将出现在描述下方的流附件中,每个属性各占一行。 这些操作将显示在帖子下的“评论”和“喜欢”链接旁边。
在随附的屏幕截图中,您将看到属性和操作的外观。 第一个屏幕截图显示了对话框在 iPhone 上弹出时的外观。 第二个屏幕截图显示了带有属性对象的 Facebook 帖子。 第三个屏幕截图显示了包含属性和操作对象的 Facebook 帖子。
希望这对您有所帮助。
关于iphone - 如何使用来自 iPhone 应用程序的 FBConnect 在我的 feed-post 中包含一个链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5574433/