gpt4 book ai didi

ios - 未配置应用程序时在 Facebook 上分享

转载 作者:行者123 更新时间:2023-11-28 08:38:23 24 4
gpt4 key购买 nike

我想在 Facebook 上发帖。为此,我使用了 SLComposeViewController。我只是想问一下,如果用户没有在手机中配置其应用程序,我该如何分享。有什么方法可以让我在浏览器中打开它然后发布任何内容。 假设我想发布任何字符串 say "hello there"。所以我保留这个字符串,打开 safari 并在那里登录。在我登录后,字符串会自动发布

if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook) {
let fbShare:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
fbShare.completionHandler = {
result in
switch result {
case SLComposeViewControllerResult.Cancelled:
//Code to deal with it being cancelled
break

case SLComposeViewControllerResult.Done:
//Code here to deal with it being completed
break
}
}
refrenceViewController.presentViewController(fbShare, animated: true, completion: nil)

} else {
//open safari and post it there
}

最佳答案

我使用以下代码将视频发布到 facebook。您可以使用类似的方法发布您的文本。

NSData *data = [NSData dataWithContentsOfURL:outputFileURL];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
data, @"video.mp4",
@"video/mp4", @"contentType",
caption, @"description",
nil];
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/me/videos"
parameters:params
HTTPMethod:@"POST"];

[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
if(!error) {
DDLogDebug(@"result %@",result);
} else {
DDLogError(@"error description : %@",error.description);
[Helper showToast:[NSString stringWithFormat:@"Unable to share to Facebook : Error: %@",[error localizedDescription]] withDuration:1];
}
}];

当然,在此之前您需要确保您已经获得了 FBSDKAccess token 。您可以从 facebook sdk 查看完整文档 https://developers.facebook.com/docs/ios/graph

关于ios - 未配置应用程序时在 Facebook 上分享,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37068096/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com