Frictionless facebook sharing in Android
Asked Answered
C

1

6

User has to click the post button in the share dialog every time they complete a level.I need to eliminate this hardship for user. As of now I have created a custom story and requesting user to click post every time.

Question :

  1. I heard of frictionless FB post for the Open graph stories. Is it possible in android ?

  2. If frictionless FB post is available in android, could you please point be the correction in my code that I have pasted below.

  3. If frictionless FB post is available in android, What is the permission that I need to get from user ?

Code

    ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
            .putString("og:type", "puzzlegameballmania:level")
            .putString("og:title", "Cleared Level-1 !!!")
            .putString("og:image", "http://ixxxxwsz.jpg")
            .putString("og:url", "https://play.google.com/store/apps/details?id=com.gamxxxxx.android")
            .putString("og:description", "Color of the balls matters more. Lets break the goal and go higher !")
            .putString("puzzlegameballmania:level:title", "LEVEL 1")
            .build();

    // Create an action
    ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
            .setActionType("puzzlegameballmania:clear")
            .putObject("puzzlegameballmania:level", object)
            .build();

    // Create the content
    ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
            .setPreviewPropertyName("puzzlegameballmania:level")
            .setAction(action) 
            .build();

    ShareDialog.show(AndroidLauncher.this, content);
Commute answered 18/11, 2015 at 14:7 Comment(0)
H
1
  1. Yes
  2. Do not use ShareDialog, instead use ShareApi, here's some sample code
  3. publish_actions permission is required, and your app will be reviewed by Facebook

You may also want to read this Facebook developer post, which seem to discourage implicit/automated posting. A warning to the user is displayed if the app has not been reviewed.

Edit


Before using ShareApi, first check to see if the app has the required permission:

private boolean hasPublishPermission() {
    AccessToken accessToken = AccessToken.getCurrentAccessToken();
    return accessToken != null && accessToken.getPermissions().contains("publish_actions");
}

If not, execute code below to request the permission:

LoginManager.getInstance().logInWithPublishPermissions(
          this, Arrays.asList("publish_actions"));

If you use ShareApi without the proper permission, it will fail and onError(FacebookException) method will be called, assuming you have passed a FacebookCallback to ShareApi.

Haemophiliac answered 21/11, 2015 at 11:40 Comment(3)
Thanks for answering the post. Regarding the Question # 2, I refereed the sample code. It request the login with "Publish_Permission" . 1. Once after the user provides the "Publish Permission" the post is done automatically ? 2. From next time onwards, the post will be done automaticallly like in candy crush ? 3. If the "Publish_Permission" is revoked by editing his permission using laptop / other device. How the code will react ? Anything has to be taken care ?Commute
1. Not sure where you see "Publish_Permission", it should be "publish_actions"; 2. There won't be a "first time", the code provided will automatically publish for user without users' explicit consent, which is why Facebook's review is required; 3. please see modified answerHaemophiliac
The answers are good ! Though I found the answer.. I am not going to use the implicit / automatic posting. As Kai has mentioned It is being ditched by FB in recent times. Not even shows up in timeline.Commute

© 2022 - 2024 — McMap. All rights reserved.