我可以通过以下方式成功地使用 SLRequest 发布到 Facebook:
- (void)postScoreWithFBAccount:(ACAccount *)facebookAccount
{
NSString *messageToPost = [self.myString stringByAppendingString:@"https://www.example.com"];
NSDictionary *fbParameters = @{@"message": messageToPost};
NSURL *feedURL = [NSURL URLWithString:@"https://graph.facebook.com/me/feed"];
SLRequest *updateFeedRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodPOST URL:feedURL parameters:fbParameters];
updateFeedRequest.account = facebookAccount;
[updateFeedRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
{
if (responseData )
{
NSLog(@"Received Response: %@", [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]);
if (urlResponse.statusCode >= 200 && urlResponse.statusCode < 300)
{
}
else
{
NSLog(@"HTTP %d Returned", urlResponse.statusCode);
}
}
else
{
[self showErrorAlertWithMessage:@"Unknown error occured, try again later!"];
}
}];
}
我想我可以通过在我的消息字符串中附加一个 url 来简单地附加一个 url。问题是,即使它被识别为 facebook 上的链接,在 facebook 上浏览时也不会显示预览,就像其他 url 一样。有谁知道我如何附加一个类似于 SLComposerViewController 的 url,而是通过 SLRequest?