简体   繁体   中英

Send app notification to a friend in Facebook

I'm totally new in Facebook API. I have created a Facebook app and through a java web app I want to send requests to invite my friends to use my app and redirect them to the app download page (or at the moment to any webpage, eg. www.google.com).

I've followed these steps: https://developers.facebook.com/docs/reference/dialogs/requests/

But I don't know if this is what I'm looking for. Please any help would be great !

The code I wrote is:

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html">
<h:head>
    <title>Facelet Title</title>
</h:head>
<h:body>
    <div id="fb-root"></div>
    <script src="http://connect.facebook.net/en_US/all.js"></script>
    <p>
        <input type="button"
               onclick="sendRequestToRecipients(); return false;"
               value="Send Request to Users Directly"
               />
        <input type="text" value="User ID" name="user_ids" />
    </p>
    <p>
        <input type="button"
               onclick="sendRequestViaMultiFriendSelector(); return false;"
               value="Send Request to Many Users with MFS"
               />
    </p>

    <script>
        FB.init({
            appId: '151779115008427',
            frictionlessRequests: true
        });

        function sendRequestToRecipients() {
            var user_ids = document.getElementsByName("user_ids")[0].value;
            FB.ui({method: 'apprequests',
                redirect_uri: 'http://www.google.com',
                message: 'My Great Request',
                to: user_ids
            }, requestCallback);
        }

        function sendRequestViaMultiFriendSelector() {
            FB.ui({method: 'apprequests',
                message: 'My Great Request'
            }, requestCallback);
        }

        function requestCallback(response) {
            // Handle callback here
        }
    </script>
</h:body>

I get the next error:

我在FB请求中的错误

I had to set as redirect_uri the baseURL from my URL where I launched the request (in my case URL = localhost:8080/FB_Test) so the baseURL that I have to set in the redirect_uri in my Website with Facebook login is: localhost:8080.

This link passed by @Anvesh Saxena helped me a lot !! Link: Facebook API error 191

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM