javascript 如何直接从浏览器打开 Facebook 应用程序以共享视图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25313299/
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
How to open Facebook App from browser directly to share view
提问by ruhungry
EDIT: What are all the custom URL schemes supported by the Facebook iPhone app?
编辑:Facebook iPhone 应用程序支持的所有自定义 URL 方案是什么?
I have got a web page where I got a Facebook
sharing button.
我有一个网页,其中有一个Facebook
共享按钮。
Now, I am dealing with iPhone
users with already installed Facebook App
.
现在,我正在处理iPhone
已安装Facebook App
.
When the user clicks share
on the page I do not want to open Facebook page, I would like to open the Facebook App for him.
当用户点击share
页面时我不想打开Facebook页面,我想为他打开Facebook App。
I have already added a piece of code:
我已经添加了一段代码:
<a href="fb://" id="shareButton">Open FB Profile</a>
This piece of code will open for user Facebook App. I would like to open the App directly with sharing view. Let's say I would like to open the App with link https://stackoverflow.com/
and waiting for user confirmation (or even just post it without any user contribution).
这段代码将为用户 Facebook 应用程序打开。我想直接用共享视图打开应用程序。假设我想打开带有链接的应用程序https://stackoverflow.com/
并等待用户确认(或者甚至只是在没有任何用户贡献的情况下发布它)。
I found a page with IPhone URL Schemesbut there is not something like fb://share
.
我找到了一个包含iPhone URL Schemes的页面,但没有类似fb://share
.
Has someone already implemented this way of sharing data with Facebook App?
有人已经实现了这种与 Facebook App 共享数据的方式吗?
I will be really happy to see your solutions and, if it is possible, a piece of code.
我会很高兴看到你的解决方案,如果可能的话,还有一段代码。
I tried to use
我试着用
<a href="fb://post?message=helloworld" id="shareButton">Open FB Profile</a>
but nothing happens - it still opens Facebook App but there is not any post on my timeline. In fact, even fb://map
opens the Facebook App in main view...
但没有任何反应 - 它仍然打开 Facebook 应用程序,但我的时间轴上没有任何帖子。事实上,即使fb://map
在主视图中打开 Facebook 应用程序......
Thank you in advance
先感谢您
EDIT:
编辑:
I tried to use another way to publish something but it is not what I really want to do. I would like to open Facebook App with dialog and ask user to share something(in fact, to accept what I want to share).
我试图用另一种方式发布一些东西,但这不是我真正想做的。我想用对话框打开 Facebook 应用程序并要求用户分享一些东西(实际上,接受我想分享的东西)。
With the Graph API ExplorerI am able to do a GET
/POST
to the current Facebook profile. I wrote also an easy JS script which does the same action:
使用Graph API Explorer,我可以对当前的 Facebook 个人资料执行GET
/ POST
。我还写了一个简单的 JS 脚本,它执行相同的操作:
<script type="text/javascript">
function publishOnFacebook() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
console.log(xmlhttp.status);
}
}
xmlhttp.open("POST", "https://graph.facebook.com/me/feed?" +
"message=https://stackoverflow.com/q/25313299/1021970" +
"&access_token=my_token", true);
xmlhttp.send();
}
</script>
It works, but it is not exactly what I want to. It looks like this:
它有效,但这并不完全是我想要的。它看起来像这样:
without any picture or preview.
没有任何图片或预览。
回答by Bj?rn Kaiser
The Facebook app does not officially support deep linking so what you are trying to do is not possible (right now).
Facebook 应用程序不正式支持深层链接,因此您尝试做的事情是不可能的(现在)。
A bigger problem I see, how will you check if the Facebook app is already installed? Mobile Safari does not provide such functionality and trying to open an URL scheme the iOS device does not understand will lead to an ugly error message, just sayin'...
我看到一个更大的问题,你将如何检查 Facebook 应用程序是否已经安装?Mobile Safari 不提供此类功能,尝试打开 iOS 设备不理解的 URL 方案将导致丑陋的错误消息,只是说......