Search code examples
facebook-graph-apiposttypeswebcustom-action

"Object is of Type Website" error when trying to publish custom action


When I try to publish a custom action I am get an error (below) claiming that the URL representing my object is of type website. As you can see from my object html I have included a. og:type '{app_namespace}:{object_name}' tag, in fact this code was mostly generated by the developer app. I have successfully published custom actions in the past for other apps and I cannot figure out what is different this time. Any suggestions would be appreciated.

Facebook Error:

{"error":{"message":"(#3502) Object at URL {URL} has og:type of 'website'. The property 'issue' requires an object of og:type '{app_namespace}:{object_name}'. ","type":"OAuthException","code":3502}}

Object Html:

<html>
  <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# {app_namespace}: http://ogp.me/ns/fb/{app_namespace}#">
    <meta property="og:type"   content="{app_namespace}:{object_name}" /> 
    <meta property="fb:app_id" content="{app_id}" /> 
    <meta property="og:url"    content={URL for this Html} /> 
    <meta property="og:title"  content="Sample title" /> 
    <meta property="og:image"  content="https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png" />
  </head>
<body>
</body>
</html>

Code I'm using to publish the action:

<head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script type="text/javascript">
        function clickHandler() {
            FB.getLoginStatus(function (response) {
                if (response.authResponse) {
                    FB.api('/me/{app_namespace}:{action_name}?{object_name}={object_url}', 'post', function (response) {
                        alert(JSON.stringify(response));
                    });
                } else {
                    //If user not logged in initiate login process
                    FB.login(function (response) {

                        if (response.authResponse) {
                            FB.api('/me/{app_namespace}:{action_name}?{object_name}={object_url}', 'post', function (response) {
                                alert(JSON.stringify(response));
                            });
                            //actionPublish();
                        } else {
                            //user cancelled login or did not grant authorization
                        }
                    }, {
                        scope: 'publish_actions'
                    });
                }

            });
        }

        $(document).ready(function () {
            window.fbAsyncInit = function () {
                FB.init({
                    appId: '{app_id}',
                    status: true,
                    cookie: true,
                    xfbml: true,
                    oauth: true
                });

                // run once with current status and whenever the status changes
                FB.getLoginStatus(updateButton);
                FB.Event.subscribe('auth.statusChange', updateButton);
            };

            (function () {
                var e = document.createElement('script');
                e.async = true;
                e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
                $("#fb-root").append(e);
            }());
        });
    </script>
</head>

<body>
    <div id="fb-root"></div>
    <button id="publishButton" onclick=clickHandler(); return false " >Publish</button>
</body>

Edit:

If I paste the fb object URL into the debug tool I get the following error:

"There was an error in fetching the object at URL 'http://www.thepropagator.com/takeAction/draft_1/demos3/issue_4.php', or one of the the URLs specified via a redirect or the 'og:url' property including one of http://www.thepropagator/takeAction/draft_1/demos3/issue_4.php."

If I try blocking out the URL tag all together the error goes away, in either case when I try to publish an action Facebook sends back the error saying that the object is of type website.


Solution

  • I ended up creating a new Facebook app. That app had the same problem, but after tweaking it a little (both with the debugger and my code I started working. I'm not sure what the take away is here, but I believe that the problem may have had as many as three roots, bugs on my end, Facebook Caching and caching on my end.

    Thanks to every one for their responses.