How to share in this format? - android

How to share icon,text,url of the app as shown in the above image? Icon should be sent from drawable, I have tried all the shareintents.putExtras() and etc.. nothing is working for me.

Short answer: This isn't your job, it's the shared-to app's job.
Explanation: Facebook created a protocol called Open Graph, which apps like Facebook and Whatsapp use to get info about the what image to be displayed and what text to show.
To be able to have something like your included picture, you'd have to first own the website you are sharing links to, then you'd have to include this meta data in your html:
<html prefix="og: http://ogp.me/ns#">
<head>
<meta property="og:title" content="Text to be displayed." />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content="Possibly a deep link to your app." />
<meta property="og:image" content="Image to be displayed."
/>
...
</head>
...
</html>
Finally in your android app you have to share a link to this website, possibly deep-linking into your app.

Related

Posting links to FB from Unity

I am trying to post a link to FB in Unity using the FB SDK.
First I used the example given
FB.FeedShare(
null,
new Uri("https://developers.facebook.com/"),
"title",
"caption",
"description",
new Uri("https://imgur.com/a/IUwesX7"),
null,
HandleResult);
This works perfectly - link gets posted and has a preview picture (take from the first link). In fact, the link works so well that clicking on the pic opens MY app even though the page has no meta tags pointing to my app! How does that happen?
However, when I replace the links with my own it doesn't work:
FB.FeedShare(
null,
new Uri("http://anykey.co.il/deeplinks/duckduckduck.html/"),
"title",
"caption",
"description",
new Uri("http://anykey.co.il/deeplinks/feature.png"),
null,
HandleResult);
The link works ok but I don't get a preview picture. I get a placeholder with the name of my site. The placeholder is clickable and opens my app on my device but there is no pic
This is my html:
<!DOCTYPE html>
<HTML xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="http://ogp.me/ns/fb#">
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE></TITLE>
<meta property="al:android:url" content="duckduckduck://story/1234">
<meta property="al:android:package" content="il.co.anykey.games.duckgames.duckduckduck">
<meta property="al:android:app_name" content="DuckDuckDuck">
<meta property="og:title" content="Duck Duck Duck" />
<meta property="og:type" content="website" />
<meta property="og:image" content="https://static.xx.fbcdn.net/rsrc.php/v3/ye/r/lWB96Z8sFtt.png" />
<STYLE TYPE="text/css">
body{font-family:Verdana,Geneva,sans-serif;font-size:16px;line-height:1.4em;color:#333;background-color:White;}
</STYLE>
</HEAD>
<BODY>
<A><IMG SRC="feature.png"></A>
<H1></H1>
<HR>
</BODY>
</HTML>
This is what I see when posting from my app:
Even stranger, if I copy the HTML from the FB link and put it on my site I get no picture.
What am I missing here? Does my website need to be authorised or something?
After burning many hours it turned out that removing the "/" from the end of my Url solved the problem.
Not sure why that is but now it is all working well.

How to get the website image/logo with jsoup in Android

I'm trying to show a preview of URL with jsoup in android.
But my concern now is that I can not decide which image to show in preview. What I want is to show the website image, such as the "F" logo for Facebook, "t" logo for Twitter.
So, can anyone help me with this problem?
I guess you are looking for favIcon.
a favIcon might be in following ways-
like
<head>
<link rel="icon" href="http://example.com/image.ico" />
</head>
or
<head>
<link rel="icon" href="http://example.com/image.png" />
</head>
or
<head>
<meta content="/images/google_favicon_128.png" itemprop="image" />
</head>
For fist 2 types-
Connection con2=Jsoup.connect(url);
Document doc = con2.get();
Element e1=doc.head().select("link[href~=.*\\.(ico|png)]").first(); // example type 1 & 2
String imageUrl1=e1.attr("href");
Element e2 = doc.head().select("meta[itemprop=image]").first(); //example type 3
String imageUrl2=e2.attr("itemprop");
then load the imageUrl in ImageView.

How to create and use self hosted objects to share custom stories in Android?

I am developing a game app. And I am sharing facebook custom stories in my app.I have created a self hosted object(html page).
I want to use that same self hosted object in android,ios and Facebook canvas app.
I have already done custom story sharing without using self hosted object for android app and below is my code for the same
OpenGraphObject objProperty = OpenGraphObject.Factory.createForPost("namespace:level");
objProperty.setProperty("title","Title");
objProperty.setProperty("image","http://www.example.com/jokedemo/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);
FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(FBActivity.this, action,"namespace:unlock", "level").build();
where unlock is my action and level is my object.
But I want it to do using self hosted object that I have created so that I can use same object for all platforms (Android, IOS , Web).
In documentation it is mentioned that Self-Hosted Objects are more useful for multi platform app than using Object api.
I followed this https://developers.facebook.com/docs/opengraph/using-objects/#selfhosted document but couldn't found anywhere there how to use it on Android.
My code for creating an self hosted object (html page)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta property="fb:app_id" content="*************" />
<meta property="og:type" content="namespace:level" />
<meta property="og:title" content="Title" />
<meta property="og:url" content="https://example.com/namespace/level.html" />
<meta property="og:description" content="Can you beat me?" />
<meta property="og:image" content="https://example.com/namespace/image/abc.png" />
</head>
<body>
</body>
</html>
If I want to use self hosted object in my Android what will be the changes in my working code or I have to do it in another way ?
Any suggestion will be highly appreciated, Thank you in advance.
Finally I solved it , actually method was there in the document itself , but it wasn't specifically mentioned there that this code will be used for self hosted object.
Below is my code :
OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
action.setProperty("level","https://example.com/namespace/level.html"); //here "level" is the Object name and url is the self hosted object
action.setType("namespace:unlock"); //"unlock" is the Action name
FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(FBActivity.this, action, "level").build();
There is an example of using a URL (self hosted object) in the FB docs. Although they now refer to it as an app owned object. Just about to test it.
https://developers.facebook.com/docs/ios/ui-controls#share-appownedobjects

facebook sharing video not playing

i am using codova 2.9.0. i give option to sharing video and image in facebook via cordova facebook connect plugin. Shared successfully. but when i click video in facebook page i got this error
Sorry, the application you were using is misconfigured. Please try again later.
and it have two buttons Go Home and Find Another App
this is my code:
FB.ui({
method: 'feed',
name: '',
caption: '',
description: des,
link: 'http://apps.facebook.com/mobile-start/',
source: postimage,
picture: url,
actions: [{ name: 'Get Started', link: 'http://apps.facebook.com/mobile-start/' }],
},
function(response) {
console.log('publishStory UI response: ', response);
});
what i missing?
I have found the solution Here
What you need to do is
The first line is a modification of the HTML head tag. This is required in your page for either active or passive sharing.
The first meta tag, shown in bold, is required for passive sharing, because you must have a Facebook app for passive sharing, as detailed in Passive App Setup.
Highlighted in italics are values that you must supply to this template.
So meta tag code will be like
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# video: http://ogp.me/ns/video#">
<!-- The following tag is required for passive sharing -->
<meta property="fb:app_id" content="yourFacebookAppIdHere" />
<meta property="og:type" content="video.other" />
<meta property="og:title" content="yourTitleHere" />
<meta property="og:description" content="yourDescriptionHere" />
<meta property="og:url" content="yourURLwithTheEmbeddedVideo">
<meta property="og:image" content="yourImageUrlHere"/>
<meta property="og:video" content="yourUrlHere" />
<meta property="og:video:secure_url" content="yourSecureUrlHere" />
<meta property="og:video" content="http://player.ooyala.com/player.swf?embedCode=YourOoyalaEmbedCodeHere&keepEmbedCode=true" />
<meta property="og:video:secure_url” content="https://player.ooyala.com/player.swf?embedCode=YourOoyalaEmbedCodeHere&keepEmbedCode=true" />
<meta property="og:video:type" content="application/x-shockwave-flash" />



how to access local data from external webpage?

I'm trying to access the data inside the assets/css from an external HTML file.
The process goes like this:
<html>
<head>
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, height=device-height, user-scalable=yes" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>ola</title>
<link rel="stylesheet" type="text/css" href="file:///android_asset/css/main.css" />
<link rel="stylesheet" type="text/css" href="file:///android_asset/css/sch.css" />
<script type="text/javascript" src="file:///android_asset/css/ethan.js" />
<script type="text/javascript" src="scripts/allinone.js" />
</head>
<body>
<input id="btnTest1" name="button" type="button" style="height:0px;width:0px;" />
</body>
</html>
So here the thing is that, I'm actually calling the HTML file using a link (since the HTML file is not locally present). But main.css, sch.css and ethan.js are locally present in the assets/css folder.
What I'm trying to do is to load the allinone.js which is obviously external and the other three files into the which are internal and run the script.
I found "file:///android_asset/css/main.css" but it looks like it doesn't work.
Please help....
I would be curious to know more about the use case here. My understanding is this:
You're loading an externally hosted HTML file into an Android Webview
You need to overlay some local styles/scripts, which can't be hosted on the external site along with the HTML (presumably because you're generating them dynamically).
If that's so -- and given that the logical approach you conceived of using the file:// URI does not work -- there would seem to be two options, each making use of the webView API:
Load the HTML file from the remote source, modify it, then set it as the webView's source. Locate the tag of the remote HTML and inject your local JS / CSS inline there.
Make use of the 'loadUrl' WebView method to inject your CSS/Javascript dynamically (this seems unnecessarily complicated if #1 is an option). For example:
mWebView.loadUrl("javascript:injectJavascript(js)");
where the parameter 'js' is some inline Javascript that you load within your Android code, and injectJavascript is a method in the remote HTML file that actually inserts it into your DOM. Take an analogous approach to insert your CSS ...
Admittedly these approaches are a bit hackish. Ideally you would use a custom method of the WebView class like 'addCssToDom' or something, but as far as I can see, no such methods are available.

Categories

Resources