Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if telegram is getting data of link (user-agent is telegram)

Tags:

php

user-agent

I have a website which user has to be logged in to his/her account to view pages ... but I want to set meta tags (description, image and title) for only when someone shares the link on telegram ...

how should I do it ? thanks in advance.

like image 707
Ebrahim Tahernejad Avatar asked Sep 07 '15 14:09

Ebrahim Tahernejad


People also ask

How can I get telegram API?

Obtaining api_id Sign up for Telegram using any application. Log in to your Telegram core: https://my.telegram.org. Go to "API development tools" and fill out the form. You will get basic addresses as well as the api_id and api_hash parameters required for user authorization.


1 Answers

So. I'v found the answer by using server.com/test.php with contents:

file_put_contents("heh.txt", $_SERVER['HTTP_USER_AGENT']);

Then I gave the link to telegram inside a chat. the content of heh.txt was:

TelegramBot (like TwitterBot)

so you should use:

if($_SERVER['HTTP_USER_AGENT'] === "TelegramBot (like TwitterBot)"){
  //do something
}
like image 199
Ebrahim Tahernejad Avatar answered Nov 14 '22 22:11

Ebrahim Tahernejad