How Telegram makes the rich preview? - telegram

Anybody knows how Telegram makes the rich preview?? It would be very useful to learn about it for a development I am making. It is a server side features, so I think the code is not available. Isn't it?

It uses Open Graph protocol: http://telegram.wiki/manuals/general/link-previews

In some posts, the preview doesn't need any work from you, for example if you have a photo URL link in your post, that is an entity of the message.
But in other cases you need to add some tag in your material, for example when you add one URL that points to an article in your website, you must tag and your HTML tag must change:
<html prefix="og: http://ogp.me/ns#">
your head tag
<meta property="og:title" content="title text" />
<meta property="og:image" content="an image url that exist in your page" />
<meta property="og:url" content="current page url" />
<meta property="og:description" content="description text" />

Related

Getting Link Info ... Telegram for a Wordpress blog

I have a blog and until some weeks ago I was able to post (getting the link preview) in Telegram and Facebook. I can continue doing in Facebook, but in Telegram, it seems that something changed and now I can't get the preview. I get the message "Getting Link Info..." and in some seconds it disappears, and doesn't get the link as I used to get some weeks ago.
I didn't modify anything in my blog when it stopped working. And now, after upgrading to latest WP version, it continues failing.
As mentioned, Facebook preview continues working, so it means that Open Graph attributes are defined properly (at least as required for Facebook).
I tried to clean Telegram Cache (using WebPage bot), but the result is exactly the same. I'm not getting the preview when trying to connect. It seems that Telegram validation if failing in somewhere.
It seems that it could be the hosting blocking the Open Graph info for Telegram.
<meta property="og:image" content="mydomain.org/wp-content/uploads/2022/06/helados.jpg" />
I just tried to move just one page to a temporal hosting to easy test with it, and I have realized that if I keep the original page (with references to my domain) I can see properly, but when trying to get the preview with Telegram it doesn't work.
Now, I change the above parameter to reference to the new hosting (just the image) and... IT WORKS. I can get the link preview.
So, now I'm wondering if there is some way to avoid this, or it could be just a FW rule in my hosting trying to avoid this Telegram Preview. But as I mentioned before, it works for Facebook (the preview). A bit strange :-(
Do you know where could be the issue?
This is the URL I'm trying to get the preview: mydomain.org/helados/ ... and this are the attributes in the page:
<meta property="og:locale" content="es_ES" />
<meta property="og:type" content="article" />
<meta property="og:title" content="Helados" />
<meta property="og:description" content="Estos helados son...." />
<meta property="og:url" content="mydomain.org/helados/" />
<meta property="og:site_name" content="Mi Web" />
<meta property="article:published_time" content="2022-06-25T13:55:53+00:00" />
<meta property="og:image" content="www.mydomain.org/wp-content/uploads/2022/06/helados.jpg" />
<meta property="og:image:width" content="1024" />
<meta property="og:image:height" content="768" />
<meta property="og:image:type" content="image/jpeg" />
<meta name="author" content="Me" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:label1" content="Escrito por" />
<meta name="twitter:data1" content="Me" />
<meta name="twitter:label2" content="Tiempo de lectura" />
<meta name="twitter:data2" content="2 minutos" />

LinkedIn doesn't recognise og:image

I'm really struggling to get LinkedIn to recognise an og:image. My og tags look like this:
<meta property="og:type" content="website" />
<meta property="og:title" content="My title here" />
<meta property="og:url" content="https://www.example.com/some-page" />
<meta property="og:description" content="Description here" />
<meta property="og:image" content="https://www.example.com/og-image.png" />
So far I've tried:
checking the og:url matches the current page
checking the image exists
adding prefixprefix="og: http://ogp.me/ns#" to my HTML tag
changing that prefix to prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# website: http://ogp.me/ns/website#"
checking the site's SSL settings (as per Share on LinkedIn with og)
ensuring my image is at least 1200x672px
ensuring my image is under 5MB
I'm not sure what else there is to try. Any ideas?
Aha – just tried making it a JPG rather than PNG and LinkedIn now sees it. That's kind of shocking but hopefully that'll help someone else!

Why site info not shown in social applications

I'm developing a website, I want to show my site info in social application like telegram when my site link is set. like the image below.
I set these tag on head site:
<meta property="og:type" content="website" />
<meta property="og:title" content="title" />
<meta property="og:description" content="desc" />
but nothing happen!
What should I do?
I found that my site can not be seen from outside of my country!
and that is the problem!

How to show twitter summary card with tweets?

I have the following meta tags on all pages of my site :
<meta name="twitter-card" content="summary">
<meta name="twitter-title" content="$row["title"] />
<meta name="twitter-description" content="$row["description"]>
When I send a link from my site to twitter timline, I dont see the view summary option in my tweets. My domain is varified for twitter summary card and I echoed the data from DB, it is working file but it is not showing in tweets. Does someone know how to fix it?
I see a few minor issues with the code you're using, which are:
On Twitter's website, in sample code, there are 5 tags while your're using only 3.
Also, the name of the tags is different than what twitter has used in their sample code.
Lastly, content attribute in the last two HTML tags does not have a closing quotation (").
Try changing your code to something like the following. (Note: You'll need to edit some of the code as per columns in your db)
<meta name="twitter:card" content="$row['summary']" />
<meta name="twitter:site" content="#your-twitter-handle" />
<meta name="twitter:title" content="$row['title']" />
<meta name="twitter:description" content="$row['description']" />
<meta name="twitter:image" content="$row['img']" />
Source: Twitter

Facebook Meta Tags Not Passing to Facebook Through PHP SDK

Good day -- I'm currently using Facebook's PHP SDK to share a link (see: https://developers.facebook.com/docs/php/howto/postwithgraphapi/), but when I attempt to customize the image, title and description via the Facebook meta tags, they do not take effect (FB always renders the defaults instead).
Here is my html head information:
<head prefix="og: http://ogp.me/ns#">
<title>Share to Facebook Custom Image</title>
<meta property="og:title" content="Share to Facebook Custom Image">
<meta property="og:type" content="website">
<meta property="og:url" content="http:...">
<meta property="og:image" content="http://www.millennialmedia.com/images/home/mmedia-2.png">
<meta property="og:description" content="add a short description of the page or content">
<meta property="fb:app_id" content="751866978175179">
</head>
Can someone please advise as to what I might be doing wrong? Much obliged!
Go to facebook debugger (ex linter) and paste the url. That should help debug. Facebook caches a copy and debugger refreshes it. Try that. Another thing that might help as well is clearing your browser's cache as the last solution.
EDIT SOLVED
You are using XHTML and XHTML is strict on errors. That was causing the facebook url parser to fail getting the information due to an invalid <br /> tag that you are using (</br>). Fix that and it will work. If going on with XHTML look here for common mistakes
I recommend switching to html like so:
<!doctype html>
<head prefix="og:http://ogp.me/ns# fb:http://ogp.me/ns/fb#">
<!-- Meta -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
As for your image not displaying issue upload a bigger image bigger from 200x200 pixels if I remember correctly.

Resources