发布到Instagram故事的URL方案

时间:2017-05-31 11:05:22

标签: ios objective-c instagram instagram-api url-scheme

有没有办法将视频或照片直接发布到用户Instagram帐户的Instagram故事中?对于Instagram上的普通照片分享,您可以使用URL Scheme并直接打开编辑器。有故事的方式吗?

谢谢!

4 个答案:

答案 0 :(得分:4)

Instagram自2018年3月起正式支持此操作。https://developers.facebook.com/docs/instagram/sharing-to-stories/

对于iOS:

您需要将instagram-stories添加到应用程序LSApplicationQueriesSchemes的{​​{1}}键中。

此示例代码显示如何向Instagram应用传递背景图层图像资产和归因深度链接。

Info.plist

答案 1 :(得分:2)

knshn's answer的Swift 4.2版本:

func shareBackgroundImage() {
    let image = UIImage(imageLiteralResourceName: "backgroundImage")

    if let pngImage = image.pngData() {
        backgroundImage(pngImage, attributionURL: "http://your-deep-link-url")
    }
}

func backgroundImage(_ backgroundImage: Data, attributionURL: String) {
    // Verify app can open custom URL scheme, open if able

    guard let urlScheme = URL(string: "instagram-stories://share"),
        UIApplication.shared.canOpenURL(urlScheme) else {
            // Handle older app versions or app not installed case

            return
    }

    let pasteboardItems = [["com.instagram.sharedSticker.backgroundImage": backgroundImage,
                            "com.instagram.sharedSticker.contentURL": attributionURL]]
    let pasteboardOptions: [UIPasteboard.OptionsKey: Any] = [.expirationDate: Date().addingTimeInterval(60 * 5)]

    // This call is iOS 10+, can use 'setItems' depending on what versions you support
    UIPasteboard.general.setItems(pasteboardItems, options: pasteboardOptions)

    UIApplication.shared.open(urlScheme)
}

答案 2 :(得分:0)

您可以使用this answer将PHAsset的标识符转换为资产网址,然后使用this logic将其格式化为instagram://网址。过去只能制作传统的Instagram帖子,但截至过去几周,它实际上会提示用户是否想要在发布时提供的资产制作故事或帖子!

答案 3 :(得分:0)

如果您下载.ipa的Instagram并查看他们的Info.plist,我们可以找到:

    <key>CFBundleURLSchemes</key>
    <array>
      <string>instagram-stories</string>
      <string>fb124024574287414</string>
      <string>instagram</string>
      <string>instagram-capture</string>
      <string>fsq+kylm3gjcbtswk4rambrt4uyzq1dqcoc0n2hyjgcvbcbe54rj+post</string>
    </array>

但当然它是私人的(不是官方的)而且没有Instagram记录。如果有人现在如何使用它/查找参数,我真的很想知道!

相关问题