Posting links to FB from Unity - android

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.

Related

The mobile chrome browser native share button copies only the url without query string when using Router from NextJS

I looked into this solution history.pushState does not update url for "share ..." button on mobile Chrome.
I tried this snippet,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="canonical" href="http://localhost:3000">
<title>Test Website</title>
<script src="./jquery.min.js"></script>
</head>
<body>
Hey shan <br> <br>
<button id="btn">Click me</button>
<script>
$(document).ready(function () {
$('#btn').click(function () {
history.pushState({urlPath:'/'}, "/", "/1234?name=shan&color=87878");
});
});
</script>
</body>
</html>
This is working even without changing canonical url too. With the above code if i click the native share button in android chrome browser the string http://localhost:3000/1234?name=shan&color=87878 gets copied.
But in my actual website the same is not happening. The only change over there is Router.replace from nextjs. The approximate snippet looks like this
buttonClick = Router.replace(...)
The problem is when user clicks a button Router.replace is called with the params and everything works except the native share copies only the url http://localhost:3000/1234 not the query string.
But the querystring gets copied when i use the copy button or edit button on the browser.
I am not sure how to approach this problem, what could be the issue? Is any meta tag could block copying the queryparam?

How to share in this format?

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.

invite friends with facebook sdk error

i followed facebook documentation to invite my friends in
my application that has two platforms (android & ios) and i want to invite my friends to install the app But when found this error
so i have two platforms so i created html file in my own server and put through it (to test first with android platform then i will add ios links)
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="https://www.facebook.com/2008/fbml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>my app </title>
<meta property="al:android:urlcontent="https://fb.me/1047369566223853">
<meta property="al:android:app_name" content="myapp">
<meta property="al:android:package" content="com.myapp.android">
<meta property="og:title" content="myapp">
<meta property="og:type" content="website">
<meta property="fb:app_id" content="9935316166414594">
<meta property="og:image
content="http://myimage.jpg">
<body>
</body></html>
this is facebook documentation
<html>
<head>
<meta property="al:ios:url" content="couchinapp://invite_from_fb?
referral=123456789" />
<meta property="al:ios:app_store_id" content="123456789" />
<meta property="al:ios:app_name" content="Couchin'" />
<meta property="al:android:url" content="couchinapp://invite_from_fb?
referral=123456789" />
<meta property="al:android:app_name" content="Couchin" />
<meta property="al:android:package" content="com.mycompany.couchin" />
<meta property="al:web:url" content="http://www.couchinapp.com/myapp.html"
/>
</head>
<body>
Couchin App Link
</body>
</html>
in java code i used
String appLinkUrl= myserverip/folder/myhtmlfile.html
//myhtmlfile which contains links on my server
AppInviteContent content = new AppInviteContent.Builder()
.setApplinkUrl(appLinkUrl)
.setPreviewImageUrl(previewImageUrl)
.build();
AppInviteDialog.show(InviteFacebookFriends.this, content);
this.finish();
AppLink is not the URL of your app, but it is the URL which links to a content inside your app.
Looks like you are not using correct AppLink URL. Please verify your AppLink.
If you don't have the URL yet, you can create here

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.

Epub Reader example Issue

I try to read epub file content to convert book formats using phonegap technology.i found examples using phonegap as shown below link:
http://bytedebugger.wordpress.com/2014/05/21/cordovaphonegap-ebook-reader-for-web-and-mobile-with-epub-js-plugin/
In this examples i am tries to implements basic epub example.I tries code as shown below :
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Basic ePubJS Example</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- EPUBJS Renderer -->
<script src="../build/epub.min.js"></script>
<!-- Zip JS -->
<script src="../build/libs/zip.min.js"></script>
<!-- Inflate JS -->
<script src="../build/libs/inflate.js"></script>
<script>
EPUBJS.filePath = "../build/libs/";
</script>
<script>
var Book = ePub("content.epub");//here epub file path given
</script>
</head>
<body>
<div id="main">
<div id="prev" onclick="Book.prevPage();" class="arrow">‹</div>
<div id="area"></div>
<div id="next" onclick="Book.nextPage();"class="arrow">›</div>
</div>
<script>
Book.renderTo("area");
</script>
</body>
</html>
Error : The operation is insecure. undefined
The above example not gets any output it shows empty.I didn't get any idea about this.So can you please suggest me what to do for this?
Thanks in Advance.
First, reading this documentation: https://github.com/futurepress/epub.js/blob/master/README.md you will see an important part:
If you plan on using compressed (zipped) epubs (any .epub file)
include the minified version of zip.js
Also make sure to set EPUBJS.filePath to the directory containing inflate.js
<script src="/build/libs/zip.min.js"></script>
<script>
EPUBJS.filePath = "../build/libs/";
</script>
So, the first thing you need to do is to add theses libs.
Some browsers can block the access of a file, so if you have problems, maybe you will need to use it with a web server.

Categories

Resources