【问题标题】:Post Video on Instagram在 Instagram 上发布视频
【发布时间】:2014-03-31 08:31:12
【问题描述】:

我正在开发需要在 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 应用程序,发现我们也可以发布/上传视频。这意味着通过代码应该是可能的。有人知道吗?

提前致谢。

【问题讨论】:

    标签: ios objective-c instagram


    【解决方案1】:

    尝试使用此代码在 Instagram 上发布视频 它对我有用,希望它也对你有用

    首先您必须将视频保存到相机胶卷,然后使用它

    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];
    }
    

    【讨论】:

      【解决方案2】:

      在弃用 ALAssetLibrary 后,Instagram 也禁用了 AssetPath 参数。 您现在可以在这种情况下使用 PHAsset localIndentifier 的 localIndentifier 属性。

         NSURL *instagramURL  = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://library?LocalIdentifier=%@", placeholderForCreatedAsset.localIdentifier]];
              [[UIApplication sharedApplication] openURL:instagramURL];
              if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
                  [[UIApplication sharedApplication] openURL:instagramURL];
              }
      

      PS:这对我来说很好,但它仍然没有记录在任何地方。

      【讨论】:

        猜你喜欢
        • 2013-11-29
        • 1970-01-01
        • 2018-07-25
        • 1970-01-01
        • 2018-04-23
        • 1970-01-01
        • 2023-03-19
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多