通过 FacebookUID 快速打开 Facebook 个人资料 [英] Swift Open Facebook Profile by FacebookUID

查看:25
本文介绍了通过 FacebookUID 快速打开 Facebook 个人资料的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用他们的 Facebook UID 在 Swift 中打开用户的 Facebook 个人资料.在模拟器中,它工作并打开个人资料的网络版本并且工作正常,但是在我的实际设备上,它打开了 Facebook 本机应用程序并给我一个找不到页面"错误.

I'm trying to open a user's Facebook profile in Swift using their Facebook UID. In the Simulator, it works and opens up the web version of the profile and works fine, however on my actual device, it opens up the Facebook native app and gives me a "Page not Found" error.

guard let facebookUID = self.user?.facebookUID else {
    return
}

print(facebookUID)
let fbURLWeb: NSURL = NSURL(string: "https://www.facebook.com/(facebookUID)")!
let fbURLID: NSURL = NSURL(string: "fb://profile/(facebookUID)")!

if(UIApplication.sharedApplication().canOpenURL(fbURLID)){
    // FB installed
    UIApplication.sharedApplication().openURL(fbURLID)
} else {
    // FB is not installed, open in safari
    UIApplication.sharedApplication().openURL(fbURLWeb)
}

我做错了什么?

提前致谢!

编辑

我注意到如果用户删除或没有在他们的手机上安装 Facebook 应用程序,它将通过 Safari 正确打开配置文件,这就是为什么它在模拟器上工作,但在我的设备.但是,我还注意到,如果我尝试使用像 fb://profile/4(这是 Mark Zuckerburg 的个人资料)这样的公开个人资料,我可以让它在 Facebook 应用程序中运行.

I've noticed that if a user deletes or doesn't have the Facebook app installed on their phone, it will open up the profile correctly through Safari, which is why it worked on the simulator, but didn't on my device. However, I've also noticed I can get it to work in the Facebook app if I try a public profile like fb://profile/4 (which is Mark Zuckerburg's profile).

推荐答案

Hi 基于 文档 Facebook ID 是应用程序范围的用户 ID,因此您可以像这样使用

Hi based on documentation Facebook ID is the App-scoped User ID so you can use like

fb://profile?app_scoped_user_id=%@

但还要检查 https://developers.facebook.com/bugs/332195860270199 使用

fb://profile?app_scoped_user_id=%@

不受支持.

因此您必须在 Safari 中打开 Facebook 个人资料,或者您可以在应用程序 webview 中使用来打开用户个人资料.我检查了一些 facebook id 10000****889,10000***041 等.所有在 facebook 应用程序中都有打开的个人资料.是的,有些人有相同的错误.找到页面机器人.

So you will have to open the Facebook profile within Safari or you can use in app webview to open user profile. I have check with some facebook id 10000****889,10000***041 etc. all have open profile in facebook app.Yes some have same error.Page bot found.

可能有隐私设置->您是否希望搜索引擎外部链接到您的个人资料->否.限制搜索.

May be there is Privacy setting->Do you want search engine outside link to your profile->No. restrict search.

从 facebook Trick 获取用户 ID :

To get ids of user from facebook Trick :

1) 右键点击此人或页面的头像,选择属性,ID 将包含在页面中

1)Right click on the person or page's profile photo, select properties and the ID will be included in the page

2)在移动浏览器中,如果您打开照片,则有 ID 例如" fbid = *** & pid = 1000....89 " 所以 1000....89 将是你的用户 ID

2)In mobile browswe if you open photo there is id E.g. " fbid = *** & pid = 1000....89 " so 1000....89 will be your user id

这篇关于通过 FacebookUID 快速打开 Facebook 个人资料的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆