android – Share on facebook page throwing an error-ThrowExceptions

Exception or error:

When I’m sharing on Facebook page, getting following error :

(#100) Only owners of the URL have the ability to specify the picture, name, thumbnail or description params.

It was working fine 5-10 days ago. When searched I found following on Facebook developer site link :

“As of November 7, 2017, link customization is available however the
link must be owned by the posting page and a page access token is
required. To verify ownership, check the
ownership_permissions{can_customize_link_posts} field on the URL node.
See our Link Ownership Guide for more information. For versions 2.10
and lower, picture, name, thumbnail, and description are deprecated.
caption is deprecated for all versions.”

Any help would be appreciated!

ShareLinkContent content = new ShareLinkContent.Builder()
            .setContentUrl(Uri.parse(shareUrl))
            .build();

new ShareApi(content).share(new FacebookCallback<Sharer.Result>() {

        @Override
        public void onSuccess(Sharer.Result result) {
            shareCallback.onSuccess(result);
        }

        @Override
        public void onCancel() {
            shareCallback.onCancel();
        }

        @Override
        public void onError(FacebookException error) {
            shareCallback.onError(error);
        }
    });
How to solve:

From what I know this is a very recent change to the facebook api.
It requires the page editors to add a metatag with the page id.

https://developers.facebook.com/docs/sharing/opengraph/object-properties?hc_location=ufi

On that page please look for fb:pages

Here’s the description of fb:pages

One or more Facebook Page IDs that are associated with a URL in order
to enable link editing and instant article publishing.

In short you need to add <meta property="fb:pages" content="PAGE_ID"> in order to edit the share content.

###

i have implemented it by using ShareDialog here is the code

CallbackManager callbackManager;
ShareDialog shareDialog;
shareDialog = new ShareDialog(this);
shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
                @Override
                public void onCancel() {

                }

                @Override
                public void onError(FacebookException error) {

                }

                @Override
                public void onSuccess(Sharer.Result result) {

                }
            });
if (ShareDialog.canShow(ShareLinkContent.class)) {
                    ShareLinkContent linkContent = new ShareLinkContent.Builder()
                            .setShareHashtag(new ShareHashtag.Builder()
                                    .build())
                            .setContentUrl(Uri.parse(shareUrl))
                            .build();
                    shareDialog.show(linkContent);
                }

i hope it can help you

Leave a Reply

Your email address will not be published. Required fields are marked *