have publish_actions approved but facebook post not public - android

My android application have publish_actions submission were approved but when I post photo on facebook via my application It's not public post because my friend on facebook cannot see this that post.
final String hashTagPost = hashtag;
callbackManager = CallbackManager.Factory.create();
List<String> permissionNeeds = Arrays.asList("publish_actions"); //I added publish_actions
loginManager = LoginManager.getInstance();
loginManager.logInWithPublishPermissions(this, permissionNeeds);
loginManager.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(bitmap)
.setCaption(txtCaption.getText().toString() + " #EventPocket " + hashTagPost)
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
ShareApi.share(content, null);
Toast.makeText(PhotoActivity.this, "Post Success", Toast.LENGTH_SHORT).show();
finish();
dialog.dismiss();
}
#Override
public void onCancel() {
}
#Override
public void onError(FacebookException e) {
}
}
This a part of my application.
What I do it more?

Related

how to hide app name from Facebook wall post

I have registered an app on my Facebook account, And I am posting Photos from app to Facebook wall post, So It's showing shared via "XYZApp". So I want to remove/hide app name from post.
Check Attachment
I have Used
SharePhoto photo = new SharePhoto.Builder().setBitmap(bm).build();
SharePhotoContent content = new SharePhotoContent.Builder().addPhoto(photo).build();
Setup ContentProvider :
<provider android:authorities="com.facebook.app.FacebookContentProvider{APP_ID}"
android:name="com.facebook.FacebookContentProvider"
android:exported="true"/>
Then add SharePhotoContent Model into content.
public void dialogShare(Bitmap imagePath){
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(imagePath)
.setCaption("StudyTutorial")
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
shareDialog.show(content);
}
Also to share link content use below method :
public static void shareMessageOnFacebook(Activity activity, CallbackManager
callbackManager, String msg) {
LoginManager.getInstance().registerCallback(callbackManager, new
FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
L.e("FacebookError", loginResult.toString());
if (loginResult.getAccessToken() != null) {
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse("app url"))
.setQuote(msg)
.build();
ShareDialog.show(activity, content);
}
}
#Override
public void onCancel() {
}
#Override
public void onError(FacebookException exception) {
L.e("FacebookError", exception.getMessage());
}
});
LoginManager.getInstance().logInWithReadPermissions(activity, Arrays.asList("public_profile", "email"));
}

How to Check Facebook invite app to friends is successfully sent invitation or not sent in android [duplicate]

In the new Fb SDK 4.0 for Android you can register a callback for the LoginButton according to the docs. https://developers.facebook.com/docs/facebook-login/android/v2.3
The question is is this possible for the AppInviteDialog as well? Or is there any other way to identify if the App-Invite was successful or not?
Yes, this is possible.
public static void openDialogInvite(final Activity activity)
{
String appLinkUrl, previewImageUrl;
appLinkUrl = "your app link url";
previewImageUrl = "https://www.example.com/my_invite_image.jpg";
if (AppInviteDialog.canShow())
{
AppInviteContent content = new AppInviteContent.Builder()
.setApplinkUrl(appLinkUrl)
.setPreviewImageUrl(previewImageUrl)
.build();
AppInviteDialog appInviteDialog = new AppInviteDialog(activity);
CallbackManager sCallbackManager = CallbackManager.Factory.create();
appInviteDialog.registerCallback(sCallbackManager, new FacebookCallback<AppInviteDialog.Result>()
{
#Override
public void onSuccess(AppInviteDialog.Result result)
{
}
#Override
public void onCancel()
{
}
#Override
public void onError(FacebookException e)
{
}
});
appInviteDialog.show(content);
}
}

Posting image on Facebook timeline using Facebook SDK for Android

I have an Android app that posts user's status messages to her/his timeline on Facebook (see the code fragment which posts the message below), the problem is that I cannot post any status images like an emoji. I tried sending the image as a byte array (someone suggested that in another post) to no avail, the picture is rejected and if I post the URL of the image, Facebooks inserts the URL instead of the actual image. Is there a way to have the image posted as a real picture? I'm using Facebook SDK 4.11 for Android and Android Studio 2.1. Any hint will be welcome. Thank you
Here is code:
postParams.putString("caption", getResources().getString(R.string.app_name)); // text to post
postParams.putString("message", msg);
postParams.putString("link", "https://www.terra7.net");
if (imgUrl != null) {
//Bitmap bi = BitmapFactory.decodeResource(getResources(), imgId);
//ByteArrayOutputStream baos = new ByteArrayOutputStream();
//bi.compress(Bitmap.CompressFormat.PNG, 100, baos);
//byte[] data = baos.toByteArray();
//postParams.putByteArray("picture", data); // image to post
postParams.putString("picture", imgUrl); // image to post
}
GraphRequest request = new GraphRequest(accessToken, "me/feed", postParams, HttpMethod.POST, new GraphRequest.Callback() {
#Override
public void onCompleted(GraphResponse response) {
if (response.getError() != null) {
Toast.makeText(MoodFragment.this.getContext(), response.getError().getErrorMessage(), Toast.LENGTH_LONG).show();
}
}
});
request.executeAsync();
Try below code:
public void sharePhotoToFacebook() {
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.pic);
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(bitmap)
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
ShareApi.share(content, new FacebookCallback<Sharer.Result>() {
#Override
public void onSuccess(Sharer.Result result) {
Log.e("onSuccess ", "result " + result);
}
#Override
public void onCancel() {
}
#Override
public void onError(FacebookException error) {
Log.e("onError ", "error " + error);
}
});
}
For using above code you need publish_actions permission you can use below code for get permission:
public void getPermission() {
List<String> permissionNeeds = Arrays.asList("publish_actions");// - See more at: http://simpledeveloper.com/how-to-share-an-image-on-facebook-in-android/#sthash.v7b5g7GA.dpuf
loginManager = LoginManager.getInstance();
loginManager.logInWithPublishPermissions(this, permissionNeeds);
loginManager.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
sharePhotoToFacebook();
}
#Override
public void onCancel() {
System.out.println("onCancel");
}
#Override
public void onError(FacebookException exception) {
System.out.println("onError");
}
});
// - See more at: http://simpledeveloper.com/how-to-share-an-image-on-facebook-in-android/#sthash.v7b5g7GA.dpuf
}

Facebook Posted image shared link not working?

When we post image on facebook by my android app it's post successfully but when we click on that post on Facebook app (on mobile devices) there is a toast appear "There's a problem opening this app." but when open in WEB and click on that posted image it'll redirect to shared link successfully.
I have use this code to share post on facebook.
GraphRequest request = GraphRequest.newPostRequest(AccessToken.getCurrentAccessToken(),
"me/feed", null, new GraphRequest.Callback() {
#Override
public void onCompleted(GraphResponse response) {
Log.i(TAG, response.toString());
//checkPostStatusAndEnableButton();
}
});
Bundle postParams = request.getParameters();
postParams.putString("link",post_url);
postParams.putString("caption", caption);
request.setParameters(postParams);
request.executeAsync();
Is we have use some other action for url for mobile devices?
Try this on :
private static List<String> PERMISSIONS = Arrays.asList("public_profile","user_photos","user_videos", "email","user_likes","user_posts",
"user_hometown", "user_location","user_about_me","user_birthday",
"user_friends","user_relationship_details");
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
// App code
Log.i(TAG,"onSuccess registerCallback");
}
#Override
public void onCancel() {
// App code
Log.i(TAG,"onCancel registerCallback");
}
#Override
public void onError(FacebookException exception) {
// App code
Log.i(TAG,"onError registerCallback");
}
});
Then call this share link method :
private void shareLink() {
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse("https://developers.facebook.com"))
.build();
ShareDialog shareDialog = new ShareDialog(this);
shareDialog.show(content, ShareDialog.Mode.AUTOMATIC);
}

Post On Facebook Wall With Android

how to share post on wall from facebook sdk 4.10.0 in android?
List<String> permissionNeeds = Arrays.asList("publish_actions");
manager = LoginManager.getInstance();
manager.logInWithPublishPermissions(this, permissionNeeds);
manager.registerCallback(callbackManager,
new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
}
#Override
public void onCancel() {
System.out.println("onCancel");
}
#Override
public void onError(FacebookException exception) {
System.out.println("onError");
}
});
I'm Working With This Code...
use this code.
shareDialog = new ShareDialog(this);
callbackManager = CallbackManager.Factory.create();
shareDialog.registerCallback(callbackManager, new
FacebookCallback<Sharer.Result>() {
#Override
public void onSuccess(Sharer.Result result) {
Toast.makeText(getApplicationContext(),"Success",Toast.LENGTH_SHORT).show();
}
#Override
public void onCancel() {
Toast.makeText(getApplicationContext(),"Not Success",Toast.LENGTH_SHORT).show();
}
#Override
public void onError(FacebookException error) {}
});
if (ShareDialog.canShow(ShareLinkContent.class)) {
//Post Link with Detail On Wall....
/* ShareLinkContent content = new ShareLinkContent.Builder()
.setContentTitle("Hello Facebook")
.setContentDescription("The 'Hello Facebook' sample showcases simple Facebook integration")
.setContentUrl(Uri.parse("http://developers.facebook.com/android"))
.build();*/
//Post Image on Wall...........
Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.naturals1);
SharePhoto photo = new SharePhoto.Builder().setBitmap(image).build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
shareDialog.show(content);
}

Categories

Resources