xcode *发送到 Instagram* 欺骗 *100 个相机在 1*

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6197445/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 21:10:14  来源:igfitidea点击:

*Send to Instagram* Trick by *100 Cameras in 1*

iphoneobjective-cxcodeinstagram

提问by Di Wu

From Day One I was told that each third-party iOS app was perfectly sand-boxed and therefore there was no way for a third-party app to transfer messages other than some pre-defined urls to another app.

从第一天起,我就被告知每个第三方 iOS 应用程序都是完美的沙箱,因此第三方应用程序除了一些预定义的 url 之外,无法将消息传输到另一个应用程序。

But this Send to Instagramtrick done by 100 Cameras in 1just caught my attention. When the user triggers this action, he jumps from 100 Cameras in 1to Instagram right away (which is OK and could be easily implemented by the url trick mentioned above.) However, what is interesting is that Instagram will display the image just processed by 100 Camera in 1as if it was displaying a image from its own sandbox.

但是这个由100 个相机合一完成的发送到 Instagram 的技巧引起了我的注意。当用户触发这个动作时,他会立即从100 Cameras in 1跳转到 Instagram(这很好,可以通过上面提到的 url 技巧轻松实现。)然而,有趣的是 Instagram 会显示刚刚处理的图像100 相机合二为一,就好像它正在显示来自其自己的沙箱的图像。

I understand that Cocoa Touch must have some APIs to support this. My question is, what are they? Are they only limited to images?

我知道 Cocoa Touch 必须有一些 API 来支持这一点。我的问题是,它们是什么?它们是否仅限于图像?

Thanks a lot in advance.

非常感谢。

Edited: I understand there's the Cocoa Touch URL scheme thing, but if it's the url scheme that did the trick... the url scheme must contain info of a pointer/reference to the image. Otherwise even if we jump from 100 Cameras in 1 to Instagram, Instagram won't have access to that image.

编辑:我知道有 Cocoa Touch URL 方案,但如果是 url 方案起到了作用...... url 方案必须包含指向图像的指针/引用的信息。否则,即使我们从 100 个相机合一跳到 Instagram,Instagram 也无法访问该图像。

Edited (2nd time): Though I haven't tried yet, Tom H's answer might finally led to a solution. So I accepted his answer as the final answer. As for unset's answer, unset kept mentioning the url scheme thing (but dude, we all know that. And it's not the switching-between-apps-by-calling-url that confused us. It's how Instagram accessed that image from another app that confused us.) Since unset's answer doesn't provide much useful info and never answered my question to the point, I down-voted his answer, and I suggest those who up-voted adjust your votes accordingly. Stack Overflow is a great place because we could almost always have answers that are to the point, not because there are people who's answers are nothing wrong but are never really to the point.

编辑(第二次):虽然我还没有尝试过,但 Tom H 的回答可能最终会导致一个解决方案。所以我接受了他的答案作为最终答案。至于 unset 的回答,unset 一直在提到 url scheme 的事情(但是老兄,我们都知道这一点。让我们困惑的不是通过调用 url 在应用程序之间切换。这是 Instagram 如何从另一个应用程序访问该图像的方式让我们感到困惑。)由于 unset 的答案没有提供太多有用的信息,并且从未准确回答我的问题,因此我对他的回答投了反对票,我建议投赞成票的人相应地调整您的投票。Stack Overflow 是一个很棒的地方,因为我们几乎总能得到切中要害的答案,而不是因为有些人的答案没有错,但从来没有真正切中要害。

Edited (3rd time): The official Instagram developer pagenow gives the official solution.

已编辑(第 3 次)官方 Instagram 开发者页面现已提供官方解决方案。

If your application creates photos and you'd like your users to share these photos using Instagram, you can use the Document Interaction API to open your photo in Instagram's sharing flow.

You must first save your file in PNG or JPEG (preferred) format and use the filename extension ".ig". Using the iOS Document Interaction APIs you can trigger the photo to be opened by Instagram. The Identifier for our Document Interaction UTI is com.instagram.photo, and it conforms to the public/jpeg and public/png UTIs. See the Apple documentation articles: Previewing and Opening Files and the UIDocumentInteractionController Class Reference for more information.

When triggered, Instagram will immediately present the user with our filter screen. The image is preloaded and sized appropriately for Instagram. Other than using the appropriate image format, described above, our only requirement is that the image is at least 612px tall and/or wide. For best results, Instagram prefers opening a JPEG that is 612px by 612px square. If the image is larger, it will be resized dynamically.

An important note: If either dimension of the image is less than 612 pixels, Instagram will present an alert to the user saying we were unable to open the file. It's our current policy not to upscale or stretch images to our minimum dimension.

如果您的应用程序创建照片并且您希望您的用户使用 Instagram 分享这些照片,您可以使用 Document Interaction API 在 Instagram 的分享流程中打开您的照片。

您必须首先将文件保存为 PNG 或 JPEG(首选)格式,并使用文件扩展名“.ig”。使用 iOS 文档交互 API,您可以触发 Instagram 打开照片。我们的文档交互 UTI 的标识符是 com.instagram.photo,它符合 public/jpeg 和 public/png UTI。有关更多信息,请参阅 Apple 文档文章:预览和打开文件以及 UIDocumentInteractionController 类参考。

触发后,Instagram 会立即向用户展示我们的过滤屏幕。图像已预先加载并调整为适合 Instagram 的大小。除了使用上述适当的图像格式之外,我们唯一的要求是图像的高度和/或宽度至少为 612 像素。为获得最佳效果,Instagram 更喜欢打开 612 像素 x 612 像素正方形的 JPEG。如果图像较大,它将动态调整大小。

重要提示:如果图像的任一尺寸小于 612 像素,Instagram 将向用户显示我们无法打开文件的警告。我们目前的政策是不将图像放大或拉伸到我们的最小尺寸。

采纳答案by fulvio

If anyone's interested, here's the actual documentation needed to do such a thing:

如果有人感兴趣,这里是执行此类操作所需的实际文档:

http://instagram.com/developer/iphone-hooks/

http://instagram.com/developer/iphone-hooks/

回答by cem

Instagram has registered the URL schemeinstagram://(type "instagram://something" in your iPhones safari and hit "open"). Maybe your app has discovered the format to send images into Instagram –?or Instagram provides a documented API.

Instagram 已经注册了URL 方案instagram://(在你的 iPhone safari 中输入“instagram://something”并点击“打开”)。也许您的应用程序发现了将图像发送到 Instagram 的格式 –?或者 Instagram 提供了一个文档化的 API

For the possible parameters, check this post.

对于可能的参数,请查看此帖子

回答by Tom H

I think what's happening (or what could possibly happen, also thank you Angelo) is first:

我认为正在发生的事情(或可能发生的事情,也感谢安吉洛)首先是:

100 Cameras in 1 saves the image to Photos.app.
Then, it passes the name/filename/path of the image to Instagram (via the url scheme).
Then, Instagram retrives the photo from Photos.app, and loads it up.

100 Cameras in 1 将图像保存到 Photos.app。
然后,它将图像的名称/文件名/路径传递给 Instagram(通过 url 方案)。
然后,Instagram 从 Photos.app 检索照片,并加载它。

There is probably not a way to do this with things other than images, however if you have a look at the UIDocumentInteractionController class which lets you open files in other apps, to an extent.

除了图像之外,可能没有其他方法可以做到这一点,但是如果您查看 UIDocumentInteractionController 类,它可以让您在一定程度上打开其他应用程序中的文件。