YeppThat'sMe
YeppThat'sMe

Reputation: 1862

facebook share error: "method" is a required parameter for FB.ui()

the headline says everything. I get always this error: "method" is a required parameter for FB.ui(). But method is set to 'feed'

Is it because i currently working local on my machine and not on a really server?? App is also registered in facebook.

Any idea?

<span id='share'>SHARE</span>   
<div id="fb-root"></div>
<script>
    window.fbAsyncInit = function() {
        FB.init({appId: '2907534********', status: true, cookie: true, xfbml: true});
    };
    (function() {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol +
        '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
    }());
</script>
<script type="text/javascript">
    $(document).ready(function(){
            $('#share').click(function(e){
                e.preventDefault();
                FB.ui({
                    method: 'feed',
                    name: 'This is the content of the "name" field.',
                    link: ' http://www.hyperarts.com/',
                    picture: 'http://www.hyperarts.com/external-xfbml/share-image.gif',
                    caption: 'This is the content of the "caption" field.',
                    description: 'This is the content of the "description" field, below the caption.',
                    message: ''
                    });
                });
            });
</script>

Upvotes: 0

Views: 1637

Answers (3)

Ahmed Gaber
Ahmed Gaber

Reputation: 41

  • you must be online on server ( really server )
  • if you didn't have Facebook id in this line FB.init({appId: '2907534********', status: true, cookie: true, xfbml: true}); you must have one from this url : https://developers.facebook.com/ or search in how to create facebook app an example for ( how to create facebook app ) hyperarts.com/blog/how-to-create-facebook-application-to-get-an-app-id-for-your-website/
  • but if you already have facebook id and already know how to create app , you must put the code in the top , on the same file that you put on facebook canvas ,

as for example if you insert in canvas ( https://www.example.com/test.php ) and you must put this code at test.php

I hope your problem will be solved really soon!

Upvotes: 0

DMCS
DMCS

Reputation: 31870

The $('#share').click(function(e){ section of code should go into the window.fbAsynchInit call to ensure the framework is loaded prior to assign a click event to something that utilizes the FB.

Upvotes: 2

AndrewF
AndrewF

Reputation: 1906

I tested that very same code with my own app ID and it worked fine for me. The only difference is that I changed name, caption, and description to just be 'This', and I fixed a syntax issue at the end.

Are you sure this bit of code is the source of your error?

Upvotes: 1

Related Questions