gpt4 book ai didi

ios - 使用任何人的 sdk 或 PHPhotolibrary 在 Instagram 上共享图像?

转载 作者:行者123 更新时间:2023-12-01 18:45:52 25 4
gpt4 key购买 nike

我想将 imageurl 分享到 instagram,我很清楚 uidocumentinteraction Controller 可以做到这一点。

但据我了解,instagram 中没有用于共享图像的官方 sdk。所以我的问题是不使用 uidocumentinteraction 是否可以使用 sdk 或 PHPhotolibrary 共享图像?

最佳答案

最后我找到了解决方案。

UIImage *getImage=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imgURL]]];
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest * assetReq = [PHAssetChangeRequest creationRequestForAssetFromImage:getImage];
NSString* localId = [[assetReq placeholderForCreatedAsset] localIdentifier];
NSString *escapedString = [localId stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet alphanumericCharacterSet]];
NSURL *instagramURL = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://library?AssetPath=%@", escapedString]];

if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
[[UIApplication sharedApplication] openURL:instagramURL];
} else {
NSLog(@"Instagram app not found.");
}


} completionHandler:^(BOOL success, NSError *error) {
if (!success){
NSLog(@"%@",error);
}
}];

关于ios - 使用任何人的 sdk 或 PHPhotolibrary 在 Instagram 上共享图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36054724/

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