How to share automatically on Facebook without showing the posting dialog?

968 views Asked by At

I am integrating Facebook share functionality in my app. And I have already implemented how to share a custom story using share dialog. But every time I share something it shows me the preview dialog as given below.

enter image description here

What I intend to achieve is when I click on share button I want it to post automatically on my wall. I have given "publish_actions" and "publish_stream" permissions in my app scope.Do I need any special permission for this ?

I have seen this functionally in candy crush. While using Daily Booster Wheel after clicking on the 'Spread the word' button it doesn't pop up any share dialog but automatically share a custom story in user's wall and story looks like as below

enter image description here enter image description here

Code I am using for custom story share

OpenGraphObject objProperty = OpenGraphObject.Factory.createForPost("namespace:level"); 

objProperty.setProperty("title","Title");
objProperty.setProperty("image","http://www.example.com/demo/image/wrong.jpg");
objProperty.setProperty("url", "http://www.example.com");       
objProperty.setProperty("description", "Can you beat me?");

OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
action.setProperty("level", objProperty);  // here "level" is the object name

FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(FBActivity.this, action,"namespace:unlock","level").build();
uiHelper.trackPendingDialogCall(shareDialog.present());

It will helpful to me if somebody can provide some code snippet or any tutorial link for android as well as web app(JavaScript) to achieve above functionality.

1

There are 1 answers

2
Santi Barbat On

Your app can be banned because of that. Read Section 2.3 of the Facebook Platform Policies. This policy prohibits apps from pre-filling the caption for any photo published on behalf of a user unless the user created the content earlier in the workflow. Note that including default text is against policy even if users are able to edit the content your app created.