Android Facebook Share Dialog's content not shown in home page - android

I using "ShareDialog" for sharing a link from my app to Facebook wall. When i post a link, it shows the content only in user's timeline and not in home page. What i'm doing wrong?
I'm doing something like that:
// This is how i invokes the shareDialog
FacebookDialog shareDialog = createShareDialogBuilderForLink().build();
private FacebookDialog.ShareDialogBuilder createShareDialogBuilderForLink() {
return new FacebookDialog.ShareDialogBuilder(this)
.setPicture("picture url")
.setName("name")
.setLink("link url");
}
User's timeline:
Home page:
In home page only shows the name of the app which take it from the link i setted(app in google play) without showing the content of the link(descriptiion, name, Caption...).

Its because the user chose to not share the link publicly, do you see the little lock icon alongside the time the link was shared? It shows that link is not shared publicly, if its public the icon changes to globe icon.
What to do now?
1) I don't know whether Facebook API allows to set permissions on the post but you can try, see API documentation.
2) Many users by default set the share permission to private, see whether your account has it private by default by going in Facebook settings.

How about this
ShareDialog shareDialog = new ShareDialog(this);
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("Title")
.setContentDescription("Description")
.setContentUrl(Uri.parse("Url"))
.build();
shareDialog.show(linkContent);
}

Related

How to share Facebook App Links to Facebook with preview?

I wanna to implement a share to Facebook function to my app.My app is Android only app.The data that I want to share it to Facebook is text and image that generated by user.So basically when other user click on a "Share" button,will open the ShareDialog and post it to their Facebook account.
In order to do this,I successfully get the App Links by using the Mobile Hosting Api,I share it to facebook,then click it,it can direct to my app or Play Store.
But now the problem is,the appearance in Facebook of the app link I share is like below
I try to use .setImageUrl , .setContentDescription but this is deprecated.
Then I read on this question and try to implement my code like below
Bitmap image = null;
SharePhoto photo = null;
try {
URL url = new URL(postImageUrl);
image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
} catch (MalformedURLException e) {
e.printStackTrace();
}
if (image !=null) {
photo = new SharePhoto.Builder()
.setBitmap(image)
.setImageUrl(Uri.parse(postImageUrl))
.setUserGenerated(true)
.build();
}
// Create an object
ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
.putString("og:type", "article")
.putString("og:title", "A Fun Story in Messenglass")
.putString("og:description", postStatus)
.build();
// Create an action
ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
.setActionType("news.reads")
.putObject("article", object)
.putPhoto("image",photo)
.build();
// Create the content
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
.setPreviewPropertyName("article")
.setAction(action)
.setContentUrl(Uri.parse(Facebook app link)) //here is the app links
.build();
shareDialog.show(getActivity(),content);
By this Open Graph story,my link share to Facebook have preview,but when I click the link,then not redirect me to my app,but redirect me to App center of Facebook.
I try to submit my app for review for Open Graph story,but my developer App Dashboard dont have any Open Graph stories section.
Here is the outlook of the link in Facebook,this is good,but not lead me to my app when clicked,but lead me to App center
This is Docs I read about the Open Graph Review
https://developers.facebook.com/docs/apps/review/opengraph/
So what I missing,so I can share my app links that from Mobile Hosting Api to Facebook,with a beautiful preview?Please give me some suggestion
UPDATE
After I implement the code above and test in real device,I successfully add the user generated photo and the text to the share dialog.But when I click "Post" in the share dialog,it pop out a progress dialog "Sending" then dismiss,no any other error or something,but I check back Facebook timeline,I dont have the post that shared appear.
Here is the outlook at the share dialog in my app,but didnt appear in Facebook timeline
Can somebody tell me what I missing?What I suppose to do in order to share the applink generate by Mobile Hosting Api,and appear in Facebook timeline with preview photo or description in the post?

How to set post caption in Facebook Share using ShareLinkContent in Android?

I am developing an Android app. In my app, I am integrating Facebook API because I am sharing content from my app to Facebook. I am especially sharing link. So I am using ShareLinkContent option from official Facebook docs. I can successfully share on Facebook. But I am having a problem with this ShareLinkContent option because I cannot set the caption to post that is entered by user.
This is how I share to Facebook:
final ShareLinkContent content = new ShareLinkContent.Builder()
.setContentTitle(shareTitle)
.setImageUrl(Uri.parse(shareImageUrl))
.setContentUrl(Uri.parse(shareContentUrl))
.setContentDescription(shareDescription)
.build();
ShareApi.share(content, null);
I display preview before I share like this:
As you can see now, I can only show preview. But what I want is I want to add an EditText in the preview. The text entered will be shared as post caption on Facebook. But the problem is there is no option setCaption(textUserEntered) in the ShareLinkContent option. I also mentioned options available in the preview image as well.
How can I set post option for ShareLinkContent? That content will be entered by user. How can I get it? Is it possible to use with ShareLinkContent?
I found the solution. Actually I do not need to show custom preview to user. If I build the share content like below code, preview will the option to enter post caption will be automatically added.
final ShareLinkContent content = new ShareLinkContent.Builder()
.setContentTitle(shareTitle)
.setImageUrl(Uri.parse(shareImageUrl))
.setContentUrl(Uri.parse(shareContentUrl))
.setContentDescription(shareDescription)
.build();
ShareDialog shareDialog = new ShareDialog(this);
shareDialog.show(content);
So no need to use
ShareApi.share(content, null);

Post to Facebook wall without using ShareDialog in Facebook 4.+

I am working on an app that I want to be able to post to Facebook wall. The language used for the app is non-latin based character set. Hence, the user types the content to share using the app itself and then share it on facebook without going to the ShareDialog as the content is already typed. I am using Facebook SDK for Android 4.+. Can anyone help me on doing this? All example I got is posting using ShareDialog. Facebook SDK seems to have classes like ShareLinkContent, SharePhoto, ShareMedia but no class to attach simple text content which I am trying to do. Or, can I make the content already typed appear on the ShareDialog's EditText?
Facebook does not allow you to pre-fill the ShareDialog's text. As far as I know there also is no other way to post content on a user's wall.
What is possible is share a link using the ShareDialog, and you can pre-fill the link description and other attributes like image and title but I guess that's not what you want.
An example of that is:
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentDescription(descriptionString)
.setContentUrl(Uri.parse(urlString))
.setImageUrl(Uri.parse(pictureUrlString))
.setContentTitle(titleString)
.build();
ShareDialog dialog = new ShareDialog(this);
dialog.show(content);
private void showFacebookShareDialog() {
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("Title")
.setContentDescription(
"Share Text")
.setContentUrl(Uri.parse("http://developers.facebook.com/android"))
.build();
shareDialog.show(linkContent);
}
}

How to implement Facebook App Link in Android with example

Is it possible to post on Facebook from my Android application and this post function as App Link? Where if someone using Facebook application tapped on this post it will be directed to G.P. to install my app, and if it's installed it will open my app with enough data to view this post in my app activity?
So far I couldn't find an example that shows how to create an App Link object, and how to include data in this object to be retrieved later from intent -> extras, and I'm totally confused how to implement it in Android.
For example, from my application I want to share an http://youtube.com/xxxxx link in a post on Facebook, how to create the App Link using Facebook App Link host feature?
Edit 1:
I need to understand something about app linking, do I create an app link for each post will be posted from my application, or app link is created once to represent my application?
Edit 2:
How to get my app name to be in Blue as Instagram and clicking on it opens my application or go to my Google Play to install if not installed
Edit 3:
This is the code I use to share, but I don't get my application name a "clickable blue link" as Instagram as in the picture:
ShareDialog shareDialog = new ShareDialog(mMainActivity);
if (ShareDialog.canShow(ShareLinkContent.class))
{
ShareLinkContent linkContent;
if(aURL == null)
{
linkContent = new ShareLinkContent.Builder().build();
}
else
{
linkContent = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(aURL))
.build();
}
shareDialog.show(linkContent);
}
Shall I make a specific changes in my application settings page on Facebook dashboard?
You should use open graph actions for that. first you should create a object . then add an action type. then needs to create a story. & you have to submit for review process your facebook app. Normally share code looks like this. read the docs https://developers.facebook.com/docs/sharing/opengraph/android. & you need to use app links - https://developers.facebook.com/docs/applinks/android
// Create an object
ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
.putString("og:type", "books.book")
.putString("og:title", "A Game of Thrones")
.putString("og:description", "In the frozen wastes to the north of Winterfell, sinister and supernatural forces are mustering.")
.putString("books:isbn", "0-553-57340-3")
.build();
// Create an action
ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
.setActionType("books.reads")
.putObject("book", object)
.build();
// Create the content
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
.setPreviewPropertyName("book")
.setAction(action)
.build();
ShareDialog.show(activityOrFragment, content);
If I understand your question correctly, you want to post to facebook(a URL) from your app.
What you can do is:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, your_link_here );
startActivity(Intent.createChooser(intent, "Share via"));
This will open up a list of apps where you can share your link which includes facebook app if it is installed. Also have a look at facebook's TOS. You cannot prefill a message as it is against their policy. If you want to share some text along with your URL you will have to use facebook's SDK.
I tried the same thing. It turns out that your app should be present on app center (facebook). Then only it will turn into blue link.
In my case, I tried clicking the link, but it landed on a page which said:
Misconfigured App Sorry, "My app" hasn't been approved for display in
App Centre.
So I got the hint from this.

Android Facebook SDK FacebookDialog.shareDialogBuilder doesn't show my description

I'm using the Facebook Android SDK to post a share from my Android app, setting the link to the Google Play url but I want to fill in my own description to be displayed. My description shows up in my preview when I'm posting from my app, but when it gets displayed all that shows is "GET IT ON GOOGLE PLAY" and my description has disappeared.
I am modifying code taken from the Facebook share tutorial included in the SDK (currently using version 3.19.0), here is the ShareDialogBuilder code:
private FacebookDialog.ShareDialogBuilder createShareDialogBuilderForLink() {
return new FacebookDialog.ShareDialogBuilder(this)
.setLink(webLink)
.setName(getString(R.string.fb_name))
.setDescription("Here is my description that I want included in the post.")
.setPicture("http://www.website.com/images/icon.png");
}
I use Facebook SDK 4.0 and this method works fine
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle(getString(R.string.share_onfacebook_title))
.setContentDescription(
getString(R.string.share_onfacebook_message))
.setContentUrl(Uri.parse(getString(R.string.share_onfacebook_url)))
.setImageUrl(Uri.parse(getString(R.string.share_onfacebook_image_url)))
.build();
shareDialog.show(linkContent);
}

Categories

Resources