0

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:

My error in FB request

Joe Lewis
  • 948
  • 5
  • 18
  • 34
  • Check if your App Settings page has your `redirect_uri` in your _Website with Facebook_ login. – Anvesh Saxena Jun 18 '13 at 10:26
  • The redirect_uri is properly set in the field you mentioned, and the error persists. Any tip to do this? – Joe Lewis Jun 18 '13 at 10:54
  • Check [this](http://stackoverflow.com/questions/4691782/facebook-api-error-191) the issue is mostly always with the difference in the URL you are accessing application from and the `redirect_uri` is different from that, or is not specified in application settings – Anvesh Saxena Jun 18 '13 at 10:58
  • Thanks ! You are right, I had to set as redirect_uri the baseURL from my URL where I launched the request (in my case URL = http://localhost:8080/FB_Test/) so the baseURL that I have to set in the redirect_uri in my Website with Facebook login is: http://localhost:8080 – Joe Lewis Jun 18 '13 at 11:27
  • Please add it as an answer below and accept it, to help people with same issue in future – Anvesh Saxena Jun 18 '13 at 11:33

1 Answers1

0

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

Community
  • 1
  • 1
Joe Lewis
  • 948
  • 5
  • 18
  • 34