允许用户'关注Instagram'从我的应用程序(斯威夫特)

时间:2015-04-20 17:58:00

标签: ios swift instagram

我想将用户的Instagram帐户连接到我的应用程序,并能够让他们跟随Instagram上的其他用户(他/她选择);或至少触发Instagram应用程序并转到用户的个人资料。我目前正在使用Swift,那里的文档还不太清楚。实际上可以做我想做的事吗?如果是这样,我该怎么办?提前感谢您的帮助。

2 个答案:

答案 0 :(得分:3)

此功能可以完成工作:

如果未安装Instagram应用程序,则会在safari中打开instagram的网页。 如果已安装该应用,则会在Instagram应用中打开您想要的页面:)

func openInstagram() {


    var instURL: NSURL = NSURL (string: "instagram://user?username=Instagram")! // Replace = Instagram by the your instagram user name
    var instWB: NSURL = NSURL (string: "https://instagram.com/instagram/")! // Replace the link by your instagram weblink

    if (UIApplication.sharedApplication().canOpenURL(instURL)) {
        // Open Instagram application
        UIApplication.sharedApplication().openURL(instURL)
    } else {
        // Open in Safari
        UIApplication.sharedApplication().openURL(instWB)


    }
}

答案 1 :(得分:1)

以下是来自Instagram的ios开发人员的文档页面(您可以找到如何打开用户Instagram个人资料):https://instagram.com/developer/mobile-sharing/iphone-hooks/

可以帮助您的图书馆(连接用户帐户,关注):https://github.com/shyambhat/InstagramKit