最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to open Facebook App from browser directly to share view - Stack Overflow

programmeradmin2浏览0评论

EDIT: What are all the custom URL schemes supported by the Facebook iPhone app?

I have got a web page where I got a Facebook sharing button.

Now, I am dealing with iPhone users with already installed 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.

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 / and waiting for user confirmation (or even just post it without any user contribution).

I found a page with IPhone URL Schemes but there is not something like fb://share.

Has someone already implemented this way of sharing data with 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...

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).

With the Graph API Explorer I am able to do a GET/POST to the current Facebook profile. I wrote also an easy JS script which does the same action:

<script type="text/javascript">
    function publishOnFacebook() {
        var xmlhttp = new XMLHttpRequest();

        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4) {
                console.log(xmlhttp.status);
            }
        }

        xmlhttp.open("POST", "?" +
                "message=" +
                "&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.

EDIT: What are all the custom URL schemes supported by the Facebook iPhone app?

I have got a web page where I got a Facebook sharing button.

Now, I am dealing with iPhone users with already installed 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.

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).

I found a page with IPhone URL Schemes but there is not something like fb://share.

Has someone already implemented this way of sharing data with 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...

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).

With the Graph API Explorer I am able to do a GET/POST to the current Facebook profile. I wrote also an easy JS script which does the same action:

<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.

Share Improve this question edited May 23, 2017 at 12:31 CommunityBot 11 silver badge asked Aug 14, 2014 at 16:42 ruhungryruhungry 4,70621 gold badges57 silver badges99 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 12 +50

The Facebook app does not officially support deep linking so what you are trying to do is not possible (right now).

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'...

发布评论

评论列表(0)

  1. 暂无评论