我正在开发需要在 Instagram 上发布图片/视频的应用程序。我已经成功地使用以下代码在 Instagram 上发布了图片:
NSString* filename = [NSString stringWithFormat:@"myimage.igo"];
NSString* savePath = [imagesPath stringByAppendingPathComponent:filename];
[UIImagePNGRepresentation(myImage) writeToFile:savePath atomically:YES];
NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
{
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
self.documentInteractionController.UTI = @"com.instagram.image";
self.documentInteractionController.delegate = self;
[self.documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
}
但是没有找到任何方式将视频发布到上面。我检查了 Instagram 应用程序,发现我们也可以发布/上传视频。意思是通过code 应该是可以的。有人知道吗?
提前致谢。
最佳答案
尝试使用此代码在 Instagram 上发布视频 它对我有用希望它也对你有用
首先你必须将视频保存到 Cameraroll 然后使用它
NSString *strURL = [NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@",yourfilepath,yourCaption];
NSString* webStringURL = [strURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL* instagramURL = [NSURL URLWithString:webStringURL];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
{
[[UIApplication sharedApplication] openURL:instagramURL];
}
关于ios - 在 Instagram 上发布视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22756906/