I am Sharing a link from my Android application Using this code
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("Memory Match")
.setContentUrl(
Uri.parse("http://dl.flipkart.com/dl/"))
.setImageUrl(
Uri.parse("http://cybercom.co.in/mm/fb_banner.png"))
.setContentDescription("Download Memory Match game").build();
shareDialog.show(linkContent);
and I am getting result on my fb wall like this
but I do not want to show domain name(rounded red) on wall like above image and I want like flipkart has done like image below
they are showing text How can I do like that, where should I set that text i rounded green
Related
I am working with a project where the user will be able to share a product from my app to facebook. In this action, the user will edit the following data:
The quote/description of the product.
Set a place for the post.
Share an image from my app gallery.
When the user shares my product it generates a standard hashtag, and the user may select a place for check in.
Here is the image of the desired action.
Sharing product on Facebook
So i followed several tutorials on youtube and the documentation from facebook so i managed to use SharePhoto and Share Link with success. In my share button im using share link and setting the following properties :
String url_link_loja = "www.centauro.com.br";
ShareHashtag.Builder hashtag = new ShareHashtag.Builder();
hashtag.setHashtag("#Olympikus");
String url_imagem = "https://static.olympikus.com.br/produtos/tenis-olympikus-thin-2-feminino/91/D22-0304-791/D22-0304-791_zoom1.jpg?resize=1200:*";
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(url_imagem_test))
.setQuote(url_link_loja)
.setImageUrl(Uri.parse(url_imagem))
.setShareHashtag(hashtag.build())
.setPlaceId("Avenida Paulista")
.build();
shareDialog.show(linkContent);
Then, when i share with my app i get just a thumbnail of the image instead of a full sized image.
Share Dialog on Nexus xl
When i use Share Photo instead, i get the full image on the dialog window just the way i want, however it seems its not possible to add hashtag and quote on this object. I tried to fix this using open graph, so i used the book example from the documentation and tried do add image, but when i do, i get a callback error message that dos not specifies the problem( i already checked, its not the commom namespace error).
So, i need some advice on the matter, any insight will be helpful.
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?
I tried sharing an Image with Caption on Facebook with the help of Facebook API and the code as below:
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(image)
.setCaption("Caption is Important")
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
shareDialog.show(content);
It open up the ShareDialog but the caption wont appear in it the dialog
As per the facebook documentation shared CBroe:
https://developers.facebook.com/policy#control
According to its policy 2.3 it states that
Don't prefill captions, comments, messages, or the user message parameter of posts with content a person or business didn’t create, even if the person can edit or remove the content before sharing. You may use our Share Dialogs to prefill a single hashtag in a post, but don't prefill any content a person or business didn't create via the API.
So we are no longer allowed to pre-fill captions for images by using shareDialog or by using any other method.
You can add caption with the given method. But at share dialog of facebook. You have to manually type your caption.
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);
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);
}
}