我不能为我的生活找到如何通过HTML中的锚点简单地打开Pinterest板(通过启动APP,如果已安装)。
我看过https://developers.pinterest.com,但仍然无法找到我想要的东西。似乎大多数文档都更倾向于固定项目而不是查看。
我想要做的就是打开用户个人资料。例如,我挖出了以下内容,这对于其他社交媒体链接非常有用:
<a href="fb://profile/23050834961">Facebook</a>
<a href="twitter://user?screen_name=NHLBruins">Twitter</a>
<a href="instagram://user?username=nhlbruins">Instagram</a>
虽然我可以启动Pinterest应用程序,但我不确定在Pinterest上打开特定配置文件/电路板的参数是什么:
<a href="pinterest://">Pinterest</a>
感谢:http://handleopenurl.com/获得上述帮助,但似乎Pinterest缺席了。有线索吗?
答案 0 :(得分:8)
看起来Pinterest发布了iOS SDK,并定义了一些URL:
Pin
pinterest://pin/285063851385287883/
Board
pinterest://board/meaghanror/cats-cats-cats/
User
pinterest://user/carlrice/
答案 1 :(得分:1)
Swift 4.x
的工作代码func openSocialMedia(appURI : String, webURI : String){
let appURL = NSURL(string: appURI)!
let webURL = NSURL(string: webURI)!
if UIApplication.shared.canOpenURL(appURL as URL) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(appURL as URL, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(appURL as URL)
}
} else {
//redirect to safari because the user doesn't have Instagram
if #available(iOS 10.0, *) {
UIApplication.shared.open(webURL as URL, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(webURL as URL)
}
}
}
如何拨打电话
@IBAction func didPressInstagram(_ sender: Any) {
let appHandle = "instagram://user?username=erashukr"
let webHandle = "https://instagram.com/erashukr"
self.openSocialMedia(appURI: appHandle, webURI: webHandle)
}
@IBAction func didPressGplus(_ sender: UIButton) {
let appHandle = "gplus://plus.google.com/u/0/+Ashutoshkumarrr"
let webHandle = "https://plus.google.com/u/0/+Ashutoshkumarrr"
self.openSocialMedia(appURI: appHandle, webURI: webHandle)
}
@IBAction func didPressFacebook(_ sender: Any) {
let appHandle = "fb://profile?id=erashukr"
let webHandle = "https://facebook.com/erashukr"
self.openSocialMedia(appURI: appHandle, webURI: webHandle)
}
@IBAction func didPressTwitter(_ sender: UIButton) {
let appHandle = "twitter://user?screen_name=ace_ashu"
let webHandle = "https://twitter.com/ace_ashu"
self.openSocialMedia(appURI: appHandle, webURI: webHandle)
}
@IBAction func didPressPinterest(_ sender: UIButton) {
let appHandle = "pinterest://user/apple"
let webHandle = "https://www.pinterest.com/apple/"
self.openSocialMedia(appURI: appHandle, webURI: webHandle)
}
100%工作