Unable to post open graph custom story with new Facebook sdk 4.1

643 Views Asked by At

Im trying to use the Facebook new ShareApi to post a custom story but i can't make it work i don't know what im doing wrong.

The custom story works fine its been approved by Facebook and im currently using it in my iOS app.

First i create the object:

ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
                    .putString("og:type","clinpays:site")
                    .putString("og:title","MY_TITLE")
                    .putString("og:description","MY_DESCRIPTION!")
                    .putString("og:url",MY_URL)
                    .build();


    SharePhoto photo = new SharePhoto.Builder()
            .setBitmap(bizBitmap)
            .setUserGenerated(true)
            .build();

Then i create the action:

    ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
                    .setActionType("clinpays:checkin")
                    .putObject("clinpays:site", object)
                    .putPhoto("photo", photo)
                    .build();

Create the content:

    ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
            .setPreviewPropertyName("clinpays:site")
            .setAction(action)
            .build();

and use the shareapi:

    ShareApi.share(content,new FacebookCallback<Sharer.Result>() {
        @Override
        public void onSuccess(Sharer.Result result) {
            Log.d(Check.TAG, "Story posted! " + result);
        }

        @Override
        public void onCancel() {

            Log.d(Check.TAG, "canceled");

        }

        @Override
        public void onError(FacebookException e) {
            Log.d(Check.TAG, "error posting: "+e.getMessage() );

        }
    });

all i get in the console is:

error posting: Invalid parameter
1

There are 1 best solutions below

0
On

You need to remove the name space from setPreviewPropertyName("clinpays:site") to be setPreviewPropertyName("site"), and remove the name space from putObject of the action as well.