在Android上分享视频和贴纸图片到Instagram故事

Oli*_*Oli 6 android facebook android-intent instagram instagram-api

我如何将视频作为背景和图像共享为Instagram故事?

如果两个内容都是图像,则此文档只有一个解决方案.

https://developers.facebook.com/docs/instagram/sharing-to-stories/

我想发送背景视频和贴纸图片.这可能与Instagram故事有关吗?

我试过了,但不幸的是它不起作用:

   // Define image asset URI and attribution link URL
    Uri backgroundAssetUri = Uri.fromFile(new File(backgroundPath));
    Uri stickerAssetUri = Uri.fromFile(new File(stickerPath));

    // Instantiate implicit intent with ADD_TO_STORY action,
    // background asset, and attribution link
    Intent intent = new Intent("com.instagram.share.ADD_TO_STORY");
    intent.setDataAndType(backgroundAssetUri, "*/*");
    intent.putExtra("interactive_asset_uri", stickerAssetUri);
    intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    callbackManager.startActivityForResult(Intent.createChooser(intent, "Share"), NatShareCallbacks.ACTIVITY_SHARE_INSTAGRAM_STORY);
Run Code Online (Sandbox Code Playgroud)

但是有两个图像的例子没有问题.我主要使用SetType看问题,因为它们是两种不同的内容类型.

[编辑]

没有贴纸的视频在Android上已经适用于我,带有图像背景和图像贴纸的文档示例也非常有效.但不是视频和贴纸在一起.

它在iOS下运行没有任何问题:

NSData *backgroundVideo = [[NSFileManager defaultManager] contentsAtPath:path];

UIImage *appIcon = [UIImage imageNamed: [[[[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIcons"] objectForKey:@"CFBundlePrimaryIcon"] objectForKey:@"CFBundleIconFiles"]  objectAtIndex:0]];

// Verify app can open custom URL scheme, open
NSURL *urlScheme = [NSURL URLWithString:@"instagram-stories://share"];
if ([[UIApplication sharedApplication] canOpenURL:urlScheme]) {
    // Assign background image asset and attribution link URL to pasteboard
    //NSArray *pasteboardItems = @[@{@"com.instagram.sharedSticker.backgroundVideo" : backgroundVideo}];
    NSArray *pasteboardItems = @[@{@"com.instagram.sharedSticker.backgroundVideo" : backgroundVideo, @"com.instagram.sharedSticker.stickerImage" : UIImagePNGRepresentation(appIcon)}];
    NSDictionary *pasteboardOptions = @{UIPasteboardOptionExpirationDate : [[NSDate date] dateByAddingTimeInterval:60 * 5]};
    // This call is iOS 10+, can use 'setItems' depending on what versions you support
    [[UIPasteboard generalPasteboard] setItems:pasteboardItems options:pasteboardOptions]; [[UIApplication sharedApplication] openURL:urlScheme options:@{} completionHandler:nil];
} else {
    // Handle older app versions or app not installed case

}
Run Code Online (Sandbox Code Playgroud)

Oli*_*Oli 2

这是一个错误。

Facebook 写道:“他们现在也将这一功能添加到 Android 中,所以你现在应该能够发送带有贴纸的背景。”