telegram-crawler/data/web/blogfork.telegram.org/api/sponsored-messages.html
2024-09-17 22:21:45 +00:00

204 lines
17 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html class="">
<head>
<meta charset="utf-8">
<title>Sponsored messages</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta property="description" content="Related TL schema:
Getting sponsored messages
sponsoredMessage#bdedf566 flags:# recommended:flags.5?true can_report:flags.12?true…">
<meta property="og:title" content="Sponsored messages">
<meta property="og:image" content="">
<meta property="og:description" content="Related TL schema:
Getting sponsored messages
sponsoredMessage#bdedf566 flags:# recommended:flags.5?true can_report:flags.12?true…">
<link rel="icon" type="image/svg+xml" href="/img/website_icon.svg?4">
<link rel="apple-touch-icon" sizes="180x180" href="/img/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/img/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/img/favicon-16x16.png">
<link rel="alternate icon" href="/img/favicon.ico" type="image/x-icon" />
<link href="/css/bootstrap.min.css?3" rel="stylesheet">
<link href="/css/telegram.css?240" rel="stylesheet" media="screen">
<style>
</style>
</head>
<body class="preload">
<div class="dev_page_wrap">
<div class="dev_page_head navbar navbar-static-top navbar-tg">
<div class="navbar-inner">
<div class="container clearfix">
<ul class="nav navbar-nav navbar-right hidden-xs"><li class="navbar-twitter"><a href="https://twitter.com/telegram" target="_blank" data-track="Follow/Twitter" onclick="trackDlClick(this, event)"><i class="icon icon-twitter"></i><span> Twitter</span></a></li></ul>
<ul class="nav navbar-nav">
<li><a href="//telegram.org/">Home</a></li>
<li class="hidden-xs"><a href="//telegram.org/faq">FAQ</a></li>
<li class="hidden-xs"><a href="//telegram.org/apps">Apps</a></li>
<li class="active"><a href="/api">API</a></li>
<li class=""><a href="/mtproto">Protocol</a></li>
<li class=""><a href="/schema">Schema</a></li>
</ul>
</div>
</div>
</div>
<div class="container clearfix">
<div class="dev_page">
<div id="dev_page_content_wrap" class=" ">
<div class="dev_page_bread_crumbs"><ul class="breadcrumb clearfix"><li><a href="/api" >API</a></li><i class="icon icon-breadcrumb-divider"></i><li><a href="/api/sponsored-messages" >Sponsored messages</a></li></ul></div>
<h1 id="dev_page_title">Sponsored messages</h1>
<div id="dev_page_content"><!-- scroll_nav -->
<p>Related TL schema:</p>
<h4><a class="anchor" href="#getting-sponsored-messages" id="getting-sponsored-messages" name="getting-sponsored-messages"><i class="anchor-icon"></i></a>Getting sponsored messages</h4>
<pre><code><a href='/constructor/sponsoredMessage'>sponsoredMessage</a>#bdedf566 flags:<a href='/type/%23'>#</a> recommended:flags.5?<a href='/constructor/true'>true</a> can_report:flags.12?<a href='/constructor/true'>true</a> random_id:<a href='/type/bytes'>bytes</a> url:<a href='/type/string'>string</a> title:<a href='/type/string'>string</a> message:<a href='/type/string'>string</a> entities:flags.1?<a href='/type/Vector%20t'>Vector</a>&lt;<a href='/type/MessageEntity'>MessageEntity</a>&gt; photo:flags.6?<a href='/type/Photo'>Photo</a> color:flags.13?<a href='/type/PeerColor'>PeerColor</a> button_text:<a href='/type/string'>string</a> sponsor_info:flags.7?<a href='/type/string'>string</a> additional_info:flags.8?<a href='/type/string'>string</a> = <a href='/type/SponsoredMessage'>SponsoredMessage</a>;
<a href='/constructor/messages.sponsoredMessages'>messages.sponsoredMessages</a>#c9ee1d87 flags:<a href='/type/%23'>#</a> posts_between:flags.0?<a href='/type/int'>int</a> messages:<a href='/type/Vector%20t'>Vector</a>&lt;<a href='/type/SponsoredMessage'>SponsoredMessage</a>&gt; chats:<a href='/type/Vector%20t'>Vector</a>&lt;<a href='/type/Chat'>Chat</a>&gt; users:<a href='/type/Vector%20t'>Vector</a>&lt;<a href='/type/User'>User</a>&gt; = <a href='/type/messages.SponsoredMessages'>messages.SponsoredMessages</a>;
---functions---
<a href='/method/channels.getSponsoredMessages'>channels.getSponsoredMessages</a>#ec210fbf channel:<a href='/type/InputChannel'>InputChannel</a> = <a href='/type/messages.SponsoredMessages'>messages.SponsoredMessages</a>;</code></pre>
<p>Each time the user opens a channel, <code>channels.getSponsoredMessages</code> must be called to receive <a href="https://promote.telegram.org">sponsored messages</a> available for this channel. The result must be cached for <strong>5 minutes</strong>.</p>
<blockquote>
<p><a href="https://t.me/durov/172">More about sponsored messages on Telegram</a></p>
</blockquote>
<h4><a class="anchor" href="#displaying-sponsored-messages" id="displaying-sponsored-messages" name="displaying-sponsored-messages"><i class="anchor-icon"></i></a>Displaying sponsored messages</h4>
<p>Sponsored messages must be displayed below all other posts in the channel, after the user scrolls further down, past the last message. </p>
<p>Sponsored messages have:</p>
<ul>
<li>A title (contained in <code>title</code>)</li>
<li>A text (contained in <code>message</code>+<code>entities</code>)</li>
<li>A button at the button (label in <code>button_text</code>) that when clicked, opens the URL in <code>url</code>.<br>
A confirmation prompt should be shown before opening the URL, unless the host part of the URL matches the following regex: <code>(^|\\.)(telegram\.(org|me|dog)|t\.me|te\.?legra\.ph|graph\.org|fragment\.com|telesco\.pe)$</code>, in which case the URL should be opened without confirmation (and if it's a <a href="/api/links">deep link »</a>, it should be opened directly in-app, without passing through the browser). </li>
</ul>
<p>The message should be marked as "Recommended" instead of "Sponsored" if the <code>recommended</code> flag is set. </p>
<p>If the <code>photo</code> flag is set, it should be used to display a profile photo bubble for the sponsored message, like for messages sent in groups. </p>
<p>If the <code>sponsor_info</code> or <code>additional_info</code> flags are set, an additional "Sponsor info" menu item must be present in the message context menu (the menu that pops up when clicking on a button), that when clicked, displays the contents of the flags. </p>
<p>If set, the sponsored message should use the <a href="/api/colors">message accent color »</a> specified in <code>color</code>.</p>
<h4><a class="anchor" href="#counting-sponsored-message-views" id="counting-sponsored-message-views" name="counting-sponsored-message-views"><i class="anchor-icon"></i></a>Counting sponsored message views</h4>
<pre><code>---functions---
<a href='/method/channels.viewSponsoredMessage'>channels.viewSponsoredMessage</a>#beaedb94 channel:<a href='/type/InputChannel'>InputChannel</a> random_id:<a href='/type/bytes'>bytes</a> = <a href='/type/Bool'>Bool</a>;</code></pre>
<p>Once the entire text is shown on the screen (excluding the button), <a href="/method/channels.viewSponsoredMessage">channels.viewSponsoredMessage</a> must be called with the <code>random_id</code> of the sponsored message.</p>
<h4><a class="anchor" href="#clicking-on-sponsored-messages" id="clicking-on-sponsored-messages" name="clicking-on-sponsored-messages"><i class="anchor-icon"></i></a>Clicking on sponsored messages</h4>
<pre><code>---functions---
<a href='/method/channels.clickSponsoredMessage'>channels.clickSponsoredMessage</a>#18afbc93 channel:<a href='/type/InputChannel'>InputChannel</a> random_id:<a href='/type/bytes'>bytes</a> = <a href='/type/Bool'>Bool</a>;</code></pre>
<p>If the user either:</p>
<ul>
<li>Clicks on a link in the sponsored message</li>
<li>Opens a sponsored chat or a sponsored website via the associated button</li>
<li>Opens the sponsored chat via the sponsored message name, the sponsored message photo, or a mention in the sponsored message</li>
</ul>
<p><a href="/method/channels.clickSponsoredMessage">channels.clickSponsoredMessage</a> must be called with the <code>random_id</code> of the sponsored message.</p>
<h4><a class="anchor" href="#reporting-sponsored-messages" id="reporting-sponsored-messages" name="reporting-sponsored-messages"><i class="anchor-icon"></i></a>Reporting sponsored messages</h4>
<pre><code><a href='/constructor/sponsoredMessage'>sponsoredMessage</a>#bdedf566 flags:<a href='/type/%23'>#</a> recommended:flags.5?<a href='/constructor/true'>true</a> can_report:flags.12?<a href='/constructor/true'>true</a> random_id:<a href='/type/bytes'>bytes</a> url:<a href='/type/string'>string</a> title:<a href='/type/string'>string</a> message:<a href='/type/string'>string</a> entities:flags.1?<a href='/type/Vector%20t'>Vector</a>&lt;<a href='/type/MessageEntity'>MessageEntity</a>&gt; photo:flags.6?<a href='/type/Photo'>Photo</a> color:flags.13?<a href='/type/PeerColor'>PeerColor</a> button_text:<a href='/type/string'>string</a> sponsor_info:flags.7?<a href='/type/string'>string</a> additional_info:flags.8?<a href='/type/string'>string</a> = <a href='/type/SponsoredMessage'>SponsoredMessage</a>;
<a href='/constructor/sponsoredMessageReportOption'>sponsoredMessageReportOption</a>#430d3150 text:<a href='/type/string'>string</a> option:<a href='/type/bytes'>bytes</a> = <a href='/type/SponsoredMessageReportOption'>SponsoredMessageReportOption</a>;
<a href='/constructor/channels.sponsoredMessageReportResultChooseOption'>channels.sponsoredMessageReportResultChooseOption</a>#846f9e42 title:<a href='/type/string'>string</a> options:<a href='/type/Vector%20t'>Vector</a>&lt;<a href='/type/SponsoredMessageReportOption'>SponsoredMessageReportOption</a>&gt; = <a href='/type/channels.SponsoredMessageReportResult'>channels.SponsoredMessageReportResult</a>;
<a href='/constructor/channels.sponsoredMessageReportResultAdsHidden'>channels.sponsoredMessageReportResultAdsHidden</a>#3e3bcf2f = <a href='/type/channels.SponsoredMessageReportResult'>channels.SponsoredMessageReportResult</a>;
<a href='/constructor/channels.sponsoredMessageReportResultReported'>channels.sponsoredMessageReportResultReported</a>#ad798849 = <a href='/type/channels.SponsoredMessageReportResult'>channels.SponsoredMessageReportResult</a>;
---functions---
<a href='/method/channels.reportSponsoredMessage'>channels.reportSponsoredMessage</a>#af8ff6b9 channel:<a href='/type/InputChannel'>InputChannel</a> random_id:<a href='/type/bytes'>bytes</a> option:<a href='/type/bytes'>bytes</a> = <a href='/type/channels.SponsoredMessageReportResult'>channels.SponsoredMessageReportResult</a>;</code></pre>
<p>To report a sponsored message to Telegram's moderators, invoke <a href="/method/channels.reportSponsoredMessage">channels.reportSponsoredMessage</a>, passing the channel ID, the <code>random_id</code> of the sponsored message and an empty <code>option</code> field. </p>
<p>Note that only sponsored messages with the <a href="/constructor/sponsoredMessage">sponsoredMessage</a>.<code>can_report</code> flag set may be reported. </p>
<p>Then, if the result is:</p>
<ul>
<li>A <a href="/constructor/channels.sponsoredMessageReportResultChooseOption">channels.sponsoredMessageReportResultChooseOption</a> constructor, the user must choose a report option from the localized options available in <code>options</code>, and after selection, the method must be invoked again, passing the option's <code>option</code> field to the <code>option</code> parameter of <a href="/method/channels.reportSponsoredMessage">channels.reportSponsoredMessage</a>.<br>
The <code>title</code> field of <a href="/constructor/channels.sponsoredMessageReportResultChooseOption">channels.sponsoredMessageReportResultChooseOption</a> must be used as title of the option selection popup. </li>
<li>A <a href="/constructor/channels.sponsoredMessageReportResultAdsHidden">channels.sponsoredMessageReportResultAdsHidden</a> constructor, sponsored messages were hidden for the user in all chats. </li>
<li>A <a href="/constructor/channels.sponsoredMessageReportResultReported">channels.sponsoredMessageReportResultReported</a> constructor, the sponsored message was reported successfully. </li>
</ul>
<p>The method may also return:</p>
<ul>
<li>An <code>AD_EXPIRED</code> RPC error, for expired (too old or not found) ads</li>
<li>A <code>PREMIUM_ACCOUNT_REQUIRED</code> RPC error, if the user asked to hide sponsored messages in the chosen option, but Telegram Premium is required for this action. </li>
</ul>
<h4><a class="anchor" href="#testing-sponsored-messages" id="testing-sponsored-messages" name="testing-sponsored-messages"><i class="anchor-icon"></i></a>Testing sponsored messages</h4>
<p>For the channel <a href="https://t.me/SecretAdTestChannel">https://t.me/SecretAdTestChannel</a> the system will <strong>always</strong> return a sponsored message: promoting either a channel, a particular message in a channel, or a bot with a start parameter.</p>
<h4><a class="anchor" href="#withdrawing-ad-revenue-as-a-channel-owner" id="withdrawing-ad-revenue-as-a-channel-owner" name="withdrawing-ad-revenue-as-a-channel-owner"><i class="anchor-icon"></i></a>Withdrawing ad revenue as a channel owner</h4>
<p>Telegram has one of the <strong>most generous reward systems</strong> in the history of social media. Telegram channel owners can now receive <strong>50%</strong> of the revenue from ads displayed in their channels.</p>
<p><a href="/api/revenue">See here »</a> for more info on how to withdraw channel ad revenue, as well as view detailed revenue stats. </p>
<hr>
<h4><a class="anchor" href="#sponsored-messages-in-third-party-apps" id="sponsored-messages-in-third-party-apps" name="sponsored-messages-in-third-party-apps"><i class="anchor-icon"></i></a>Sponsored messages in third-party apps</h4>
<p>Telegram continues to grow worldwide, in part thanks to third-party apps using the Telegram API. To cover the increasing costs that come with this growth, Telegram added <a href="https://promote.telegram.org">sponsored messages</a> a paid <a href="https://t.me/durov/172">privacy-friendly way</a> to promote <strong>bots and channels</strong>. </p>
<p>If their app allows its users to <strong>access content from Telegram channels</strong>, third-party developers using the Telegram API are required to support and properly display official sponsored messages in their apps by <strong>January 1, 2022</strong>. Unfortunately, Telegram cannot financially sustain third-party apps that do not display sponsored messages and they will have to be disconnected. </p>
<p>Telegram's API usage will continue to be <strong>free of charge</strong> for all developers. The <a href="https://core.telegram.org/api/terms#3-advertising-amp-monetization">rules</a> regarding monetization in third-party apps remain the same: developers are allowed to monetize their coding efforts through advertising of their own or other legitimate means, provided that all the methods of monetization used in their apps are prominently mentioned in their app store descriptions.</p></div>
</div>
</div>
</div>
<div class="footer_wrap">
<div class="footer_columns_wrap footer_desktop">
<div class="footer_column footer_column_telegram">
<h5>Telegram</h5>
<div class="footer_telegram_description"></div>
Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed.
</div>
<div class="footer_column">
<h5><a href="//telegram.org/faq">About</a></h5>
<ul>
<li><a href="//telegram.org/faq">FAQ</a></li>
<li><a href="//telegram.org/privacy">Privacy</a></li>
<li><a href="//telegram.org/press">Press</a></li>
</ul>
</div>
<div class="footer_column">
<h5><a href="//telegram.org/apps#mobile-apps">Mobile Apps</a></h5>
<ul>
<li><a href="//telegram.org/dl/ios">iPhone/iPad</a></li>
<li><a href="//telegram.org/android">Android</a></li>
<li><a href="//telegram.org/dl/web">Mobile Web</a></li>
</ul>
</div>
<div class="footer_column">
<h5><a href="//telegram.org/apps#desktop-apps">Desktop Apps</a></h5>
<ul>
<li><a href="//desktop.telegram.org/">PC/Mac/Linux</a></li>
<li><a href="//macos.telegram.org/">macOS</a></li>
<li><a href="//telegram.org/dl/web">Web-browser</a></li>
</ul>
</div>
<div class="footer_column footer_column_platform">
<h5><a href="/">Platform</a></h5>
<ul>
<li><a href="/api">API</a></li>
<li><a href="//translations.telegram.org/">Translations</a></li>
<li><a href="//instantview.telegram.org/">Instant View</a></li>
</ul>
</div>
</div>
<div class="footer_columns_wrap footer_mobile">
<div class="footer_column">
<h5><a href="//telegram.org/faq">About</a></h5>
</div>
<div class="footer_column">
<h5><a href="//telegram.org/blog">Blog</a></h5>
</div>
<div class="footer_column">
<h5><a href="//telegram.org/apps">Apps</a></h5>
</div>
<div class="footer_column">
<h5><a href="/">Platform</a></h5>
</div>
<div class="footer_column">
<h5><a href="//telegram.org/press">Press</a></h5>
</div>
</div>
</div>
</div>
<script src="/js/main.js?47"></script>
<script src="/js/jquery.min.js?1"></script>
<script src="/js/bootstrap.min.js?1"></script>
<script>window.initDevPageNav&&initDevPageNav();
backToTopInit("Go up");
removePreloadInit();
</script>
</body>
</html>