ios - 在 Instagram 上发布视频

标签 ios objective-c instagram

我正在开发需要在 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/

相关文章:

ios - 在 GLK View Controller 中使用 GLKView

ios - Base64 图像编码 Swift 4 iOS

ios - 如何更改MapView注释中的标注气泡颜色?

javascript - Instagram Feed 光滑 slider

ios - 如何在ios中实现instagram similar like效果?

c# - Xamarin iOS 以编程方式将导航栏添加到 TableView

ios - 'RTCPeerConnection' 没有可见的@interface 声明选择器 'setLocalDescription:'

iphone - Objective-C:AutoresizingMask + 2 Subviews = 挣扎

c++ - 在 C++ 代码中使用 objc 对象?

php - 检查 Instagram 个人资料是否私密,无需身份验证