Telegram 礼物
用户可以向好友赠送礼物。收礼人可以将礼物展示在个人主页上,或将其兑换成Telegram 星星。Telegram 星星用途广泛,包括支持创作者和在小程序中购买服务。
送礼物
payments.starGiftsNotModified#a388a368 = payments.StarGifts; payments.starGifts#2ed82995 hash:int gifts:Vector<StarGift> chats:Vector<Chat> users:Vector<User> = payments.StarGifts;starGift#80ac53c3 flags:# limited:flags.0?true sold_out:flags.1?true birthday:flags.2?true require_premium:flags.7?true limited_per_user:flags.8?true id:long sticker:Document stars:long availability_remains:flags.0?int availability_total:flags.0?int availability_resale:flags.4?long convert_stars:long first_sale_date:flags.1?int last_sale_date:flags.1?int upgrade_stars:flags.3?long resell_min_stars:flags.4?long title:flags.5?string released_by:flags.6?Peer per_user_total:flags.8?int per_user_remains:flags.8?int locked_until_date:flags.9?int = StarGift;payments.checkCanSendGiftResultOk#374fa7ad = payments.CheckCanSendGiftResult; payments.checkCanSendGiftResultFail#d5e58274 reason:TextWithEntities = payments.CheckCanSendGiftResult;inputInvoiceStarGift#e8625e92 flags:# hide_name:flags.0?true include_upgrade:flags.2?true peer:InputPeer gift_id:long message:flags.1?TextWithEntities = InputInvoice; inputInvoiceStarGiftResale#c39f5324 flags:# ton:flags.0?true slug:string to_id:InputPeer = InputInvoice;messageActionStarGift#f24de7fa flags:# name_hidden:flags.0?true saved:flags.2?true converted:flags.3?true upgraded:flags.5?true refunded:flags.9?true can_upgrade:flags.10?true prepaid_upgrade:flags.13?true upgrade_separate:flags.16?true gift:StarGift message:flags.1?TextWithEntities convert_stars:flags.4?long upgrade_msg_id:flags.5?int upgrade_stars:flags.8?long from_id:flags.11?Peer peer:flags.12?Peer saved_id:flags.12?long prepaid_upgrade_hash:flags.14?string gift_msg_id:flags.15?int = MessageAction;inputPrivacyKeyStarGiftsAutoSave#e1732341 = InputPrivacyKey; privacyKeyStarGiftsAutoSave#2ca4fdf8 = PrivacyKey;---functions---payments.getStarGifts#c4563590 hash:int = payments.StarGifts; payments.getResaleStarGifts#7a5fa236 flags:# sort_by_price:flags.1?true sort_by_num:flags.2?true attributes_hash:flags.0?long gift_id:long attributes:flags.3?Vector<StarGiftAttributeId> offset:string limit:int = payments.ResaleStarGifts; payments.checkCanSendGift#c0c4edc9 gift_id:long = payments.CheckCanSendGiftResult; payments.saveStarGift#2a2a697c flags:# unsave:flags.0?true stargift:InputSavedStarGift = Bool; payments.convertStarGift#74bf076b stargift:InputSavedStarGift = Bool;
如果用户和另一个用户的userFulldisplay_gifts_button标志都已设置(通过globalPrivacySettings更改),则在与该用户的私聊中,文本字段中应始终显示一个礼物按钮:点击后,应显示礼物界面,为用户提供赠送Telegram Premium »订阅或Telegram 礼物 »的选项。
同一个送礼界面应该始终(无条件地)通过聊天选择器提供,可通过应用程序设置中的“赠送礼物”选项激活。
用户可以通过设置globalPrivacySettings标志来禁止接收特定类型的礼物,该disallowed_gifts标志对userFull中的其他用户可见。disallowed_gifts
-
使用payments.getStarGifts获取所有可用星光礼品的完整列表;此方法可能会返回一些已售罄的礼品availability_resale,这些礼品会带有标记,表示此类礼品正在转售。
-
使用payments.getResaleStarGifts获取当前正在转售的礼品。
将返回的payments.resaleStarGifts传递next_offset给下offset一个方法调用,以获取下一结果页面。如果这sort_by_price两个sort_by_num参数互斥,则当转售价格上次更改时,结果将按 unix 时间(降序)排序。
也可以使用相同的方法获取指定礼品类型的所有可用属性(payments.resaleStarGifts.attributes):要获取该属性,该attributes_hash字段必须已填充且等于某个值0。还可以
将该参数attributes_hash设置为先前返回的payments.resaleStarGifts.attributes_hash,以避免在属性未更改时重新获取属性。如果下列条件中至少有一项成立:
- attributes_hash该方法的参数未设置
- 参数offset不为空
- 传递的值attributes_hash等于服务器端的值
...payments.resaleStarGifts字段attributes将不会被返回,因为payments.resaleStarGifts字段attributes与特定类型的所有礼品相关,而不仅仅是当前页面上的礼品。
设置attributes该方法的筛选参数也不会以任何方式 影响返回的payments.resaleStarGifts字段。attributes返回的payments.resaleStarGifts字段与payments.resaleStarGiftscounters字段相关,它表示具有特定属性的礼物总数:即使未设置参数,也会返回该字段,但如果该字段非空,则不会返回该字段。attributescountersattributes_hashoffset
最后,还可以设置payments.getResaleStarGiftsattributes的参数,使其仅获取具有指定属性的礼品。如果设置了该标志但未指定特定类型的属性,则允许使用该类型的所有属性。请注意,这不会影响返回的礼品数量。
attributescounters
starGift带有标记limited_per_user,per_user_remains <= 0当前用户无法购买,因为他们已经购买了per_user_total同类型的礼物(无论是给自己还是给其他人)。
设置了特定locked_until_date标志的starGift可能要等到指定的 Unix 时间后才能购买:要验证是否如此,请调用`payments.checkCanSendGift`方法。如果礼物无法发送,
此方法将返回 `payments.checkCanSendGiftResultFail`,并附带一段本地化的描述,说明礼物无法发送的原因。
否则,它将返回`payments.checkCanSendGiftResultOk`,在这种情况下,客户端仍应检查starGift标志是否已设置,require_premium如果已设置,则要求用户购买Telegram Premium会员资格(如果他们尚未订阅)。
用户选择可发送的(非sold_out)礼物后,即可使用Telegram Stars从其余额中购买。购买方式为:调用payments.getPaymentForm,传入inputInvoiceStarGift,并传递以下参数:stars
- peer:接收礼物的用户或频道的标识符(仅当设置了channelFull时)。stargifts_available
- gift_id:礼物标识符,来自starGift。id
- message:可选消息,随礼物一起发送:此字段的最大长度在stargifts_message_length_max 客户端配置值中指定 »。
- hide_name如果设置了此选项,当收礼人决定在其个人资料中显示礼物时,您的姓名将被隐藏(但他们仍然会看到您赠送了礼物)。
-
include_upgrade设置此标志可额外预付星礼金。Telegramupgrade_stars星星,允许接收者将礼物转换为可收藏礼物,无需支付任何费用。请注意,只有在设置了星礼金
后才能设置此标志。upgrade_stars
从当前正在转售的礼品列表中购买礼品时,请传递inputInvoiceStarGiftResale参数:
- slug:取自返回的starGiftUnique,slug或取自链接
- to_id:接收礼物的用户或频道的标识符
然后,按照通常的支付流程进行»。
付款完成后,目标节点将收到我们发送的messageService,其中包含有关所收到礼物的信息。
然后,对方可以选择使用payments.saveStarGift在其个人资料中显示收到的礼物。
收到的礼物也可能根据接收方的隐私设置(inputPrivacyKeyStarGiftsAutoSavekey)自动显示在个人资料中。
或者,可以使用payments.convertStarGift将礼物转换为Telegram Stars;此操作将永久销毁礼物,并将其转换为starGift.TelegramStars,添加到用户的余额中(请注意,starGift.将小于礼物的购买价格 (starGift. ))。只有在客户端配置中指定的时间小于 2 秒的时间内收到的礼物才能转换回Telegram Stars。convert_starsconvert_starsstars
stargifts_convert_period_max
如果用户选择在个人资料中显示收到的礼物,则所有用户都可以看到,具体方法请参见此处 »。
同样的方法也可用于获取任何用户的所有子用户收到的所有礼物。
stargifts_blocked请注意,如果客户端配置标志 »设置为 true,则必须禁用礼品支持。
列出所有收到的礼物
payments.savedStarGifts#95f389b1 flags:# count:int chat_notifications_enabled:flags.1?Bool gifts:Vector<SavedStarGift> next_offset:flags.0?string chats:Vector<Chat> users:Vector<User> = payments.SavedStarGifts;---functions---payments.getSavedStarGifts#a319e569 flags:# exclude_unsaved:flags.0?true exclude_saved:flags.1?true exclude_unlimited:flags.2?true exclude_unique:flags.4?true sort_by_value:flags.5?true exclude_upgradable:flags.7?true exclude_unupgradable:flags.8?true peer:InputPeer collection_id:flags.6?int offset:string limit:int = payments.SavedStarGifts;
payments.getSavedStarGifts可用于获取好友收到的所有礼物列表,例如:
- 用户,其 peer=inputPeerUser(包括与我们不同的用户)
- 一个通道,其 peer=inputPeerChannel(包括当前登录用户不拥有的通道)
- 已连接的业务用户(当以机器人身份通过业务连接执行方法时),其 peer=受控用户的inputPeerUser
该方法的参数可用于根据各种标准筛选礼物,有关更多信息, 请参阅该方法页面。
请注意,与名称所暗示的不同,该方法可用于获取当前登录用户拥有/控制的用户和频道的“已保存”和“未保存”礼物(即已固定到个人资料和未固定到个人资料的礼物),具体取决于传递的标志。
列出具体的自有礼品
inputSavedStarGiftUser#69279795 msg_id:int = InputSavedStarGift; inputSavedStarGiftChat#f101aa7f peer:InputPeer saved_id:long = InputSavedStarGift; inputSavedStarGiftSlug#2085c238 slug:string = InputSavedStarGift;payments.savedStarGifts#95f389b1 flags:# count:int chat_notifications_enabled:flags.1?Bool gifts:Vector<SavedStarGift> next_offset:flags.0?string chats:Vector<Chat> users:Vector<User> = payments.SavedStarGifts;---functions---payments.getSavedStarGift#b455a106 stargift:Vector<InputSavedStarGift> = payments.SavedStarGifts;
payments.getSavedStarGift可用于获取有关当前登录用户控制的对等节点所拥有的特定礼物的信息。
请注意,与名称所暗示的不同,该方法可用于获取“已保存”和“未保存”的礼物(即已固定到个人资料和未固定到个人资料的礼物)。
收到频道礼物通知
---functions---payments.toggleChatStarGiftNotifications#60eaefa1 flags:# enabled:flags.0?true peer:InputPeer = Bool;
payments.toggleChatStarGiftNotifications可用于启用或禁用每次指定渠道收到礼物时接收通知的功能:它只能由具有post_messages管理员权限的管理员调用。
您将收到来自频道的messageActionStarGiftUnique和messageActionStarGift服务消息形式的通知。
别上收到的礼物
---functions---payments.toggleStarGiftsPinnedToTop#1513e7b0 peer:InputPeer stargift:Vector<InputSavedStarGift> = Bool;可以通过payments.toggleStarGiftsPinnedToTop将收到的礼物置顶在用户个人资料或拥有的频道上。
可固定到个人资料的最大礼物数量在stargifts_pinned_to_top_limit 客户端配置键中指定 »。
礼品收藏
inputSavedStarGiftUser#69279795 msg_id:int = InputSavedStarGift; inputSavedStarGiftChat#f101aa7f peer:InputPeer saved_id:long = InputSavedStarGift; inputSavedStarGiftSlug#2085c238 slug:string = InputSavedStarGift;starGiftCollection#9d6b13b0 flags:# collection_id:int title:string icon:flags.0?Document gifts_count:int hash:long = StarGiftCollection;payments.starGiftCollectionsNotModified#a0ba4f17 = payments.StarGiftCollections; payments.starGiftCollections#8a2932f3 collections:Vector<StarGiftCollection> = payments.StarGiftCollections;---functions---payments.createStarGiftCollection#1f4a0e87 peer:InputPeer title:string stargift:Vector<InputSavedStarGift> = StarGiftCollection; payments.getStarGiftCollections#981b91dd peer:InputPeer hash:long = payments.StarGiftCollections; payments.updateStarGiftCollection#4fddbee7 flags:# peer:InputPeer collection_id:int title:flags.0?string delete_stargift:flags.1?Vector<InputSavedStarGift> add_stargift:flags.2?Vector<InputSavedStarGift> order:flags.3?Vector<InputSavedStarGift> = StarGiftCollection; payments.reorderStarGiftCollections#c32af4cc peer:InputPeer order:Vector<int> = Bool; payments.deleteStarGiftCollection#ad5648e8 peer:InputPeer collection_id:int = Bool;payments.getSavedStarGifts#a319e569 flags:# exclude_unsaved:flags.0?true exclude_saved:flags.1?true exclude_unlimited:flags.2?true exclude_unique:flags.4?true sort_by_value:flags.5?true exclude_upgradable:flags.7?true exclude_unupgradable:flags.8?true peer:InputPeer collection_id:flags.6?int offset:string limit:int = payments.SavedStarGifts;
礼品收藏将多件拥有的礼品组合在一起;每件礼品可以属于一个或多个收藏。
使用payments.createStarGiftCollection创建收藏集。
使用payments.getSavedStarGifts并collection_id设置标志以从收藏集中获取礼物。
使用payments.getStarGiftCollections列出指定用户的全部星级礼物收藏。
注意:payments.getStarGiftCollectionshash的参数是通过传递所有先前返回的集合的starGiftCollection字段(而不是字段)生成的,以避免在可用集合及其内容未更改时返回任何结果。hashcollection_id
使用payments.updateStarGiftCollection可以添加、删除或重新排序收藏中的礼物,或者重命名收藏。
使用payments.reorderStarGiftCollections重新排列已拥有用户个人资料中的收藏品。
使用payments.deleteStarGiftCollection删除礼品收藏。
一个个人资料最多可以包含stargifts_collections_limit »个礼物收藏,每个收藏最多可以包含stargifts_collection_gifts_limit个礼物。
礼品收藏深度链接 »可用于分享礼品收藏。
收藏礼品
收到的礼物可以升级为收藏品。
收藏级礼物具有特殊属性,可以转让给其他用户或在 NFT 市场上拍卖。
升级礼物即可解锁全新外观,您可以从Telegram 艺术家创作的数十种自定义样式中选择。收藏品还会随机获得一组辅助属性,包括背景颜色、图标和编号。这意味着每件收藏品都是一件独一无二的艺术品——而且有些会比其他更为稀有。
将礼物升级为收藏品
messageActionStarGift#f24de7fa flags:# name_hidden:flags.0?true saved:flags.2?true converted:flags.3?true upgraded:flags.5?true refunded:flags.9?true can_upgrade:flags.10?true prepaid_upgrade:flags.13?true upgrade_separate:flags.16?true gift:StarGift message:flags.1?TextWithEntities convert_stars:flags.4?long upgrade_msg_id:flags.5?int upgrade_stars:flags.8?long from_id:flags.11?Peer peer:flags.12?Peer saved_id:flags.12?long prepaid_upgrade_hash:flags.14?string gift_msg_id:flags.15?int = MessageAction; savedStarGift#19a9b572 flags:# name_hidden:flags.0?true unsaved:flags.5?true refunded:flags.9?true can_upgrade:flags.10?true pinned_to_top:flags.12?true upgrade_separate:flags.17?true from_id:flags.1?Peer date:int gift:StarGift message:flags.2?TextWithEntities msg_id:flags.3?int saved_id:flags.11?long convert_stars:flags.4?long upgrade_stars:flags.6?long can_export_at:flags.7?int transfer_stars:flags.8?long can_transfer_at:flags.13?int can_resell_at:flags.14?int collection_id:flags.15?Vector<int> prepaid_upgrade_hash:flags.16?string = SavedStarGift;starGift#80ac53c3 flags:# limited:flags.0?true sold_out:flags.1?true birthday:flags.2?true require_premium:flags.7?true limited_per_user:flags.8?true id:long sticker:Document stars:long availability_remains:flags.0?int availability_total:flags.0?int availability_resale:flags.4?long convert_stars:long first_sale_date:flags.1?int last_sale_date:flags.1?int upgrade_stars:flags.3?long resell_min_stars:flags.4?long title:flags.5?string released_by:flags.6?Peer per_user_total:flags.8?int per_user_remains:flags.8?int locked_until_date:flags.9?int = StarGift;starGiftAttributeModel#39d99013 name:string document:Document rarity_permille:int = StarGiftAttribute; starGiftAttributePattern#13acff19 name:string document:Document rarity_permille:int = StarGiftAttribute; starGiftAttributeBackdrop#d93d859c name:string backdrop_id:int center_color:int edge_color:int pattern_color:int text_color:int rarity_permille:int = StarGiftAttribute; starGiftAttributeOriginalDetails#e0bff26c flags:# sender_id:flags.0?Peer recipient_id:Peer date:int message:flags.1?TextWithEntities = StarGiftAttribute;payments.starGiftUpgradePreview#167bd90b sample_attributes:Vector<StarGiftAttribute> = payments.StarGiftUpgradePreview;inputSavedStarGiftUser#69279795 msg_id:int = InputSavedStarGift; inputSavedStarGiftChat#f101aa7f peer:InputPeer saved_id:long = InputSavedStarGift; inputSavedStarGiftSlug#2085c238 slug:string = InputSavedStarGift;---functions---payments.getStarGiftUpgradePreview#9c9abcb1 gift_id:long = payments.StarGiftUpgradePreview; payments.upgradeStarGift#aed6e4f5 flags:# keep_original_details:flags.0?true stargift:InputSavedStarGift = Updates;
如果设置了messageActionStarGift/savedStarGift标志,则收到的礼物可以升级为收藏品礼物。can_upgrade
要预览升级后礼物可以获得的(随机选择的)属性,请调用payments.getStarGiftUpgradePreview。
要升级收到的礼物,请通过调用payments.getPaymentForm并传递带有以下参数的inputInvoiceStarGiftUpgrade ,向Telegram Stars支付starGift:upgrade_stars
- stargift收到的礼物的标识符
- keep_original_details设置此标志可将原始礼物文本、发送者和接收者保留在升级后的礼物中,作为starGiftAttributeOriginalDetails属性。
然后,按照通常的支付流程进行»。
如果礼物的原始赠送者已经按照此处的规定支付了升级费用» (由此处列出的特定标志指示»),则只需使用相同的标志调用payments.upgradeStarGift ,而无需使用payments.getPaymentForm付款流程。
升级礼物时会发出一条消息 ActionStarGiftUnique,其中包含有关新升级礼物的信息以及一些额外信息。
预付他人的升级费用
messageActionStarGift#f24de7fa flags:# name_hidden:flags.0?true saved:flags.2?true converted:flags.3?true upgraded:flags.5?true refunded:flags.9?true can_upgrade:flags.10?true prepaid_upgrade:flags.13?true upgrade_separate:flags.16?true gift:StarGift message:flags.1?TextWithEntities convert_stars:flags.4?long upgrade_msg_id:flags.5?int upgrade_stars:flags.8?long from_id:flags.11?Peer peer:flags.12?Peer saved_id:flags.12?long prepaid_upgrade_hash:flags.14?string gift_msg_id:flags.15?int = MessageAction;inputInvoiceStarGiftPrepaidUpgrade#9a0b48b8 peer:InputPeer hash:string = InputInvoice;messageActionStarGiftUnique#34f762f3 flags:# upgrade:flags.0?true transferred:flags.1?true saved:flags.2?true refunded:flags.5?true prepaid_upgrade:flags.11?true gift:StarGift can_export_at:flags.3?int transfer_stars:flags.4?long from_id:flags.6?Peer peer:flags.7?Peer saved_id:flags.7?long resale_amount:flags.8?StarsAmount can_transfer_at:flags.9?int can_resell_at:flags.10?int = MessageAction;
赠送礼物时,赠送者可以通过在购买礼物时设置`inputInvoiceStarGift`来支付升级费用。生成的`messageActionStarGift`会设置该标志,关联的`savedStarGift`也会设置该标志并填充已支付的金额。include_upgrade
prepaid_upgrade upgrade_stars
也可以在事后付费升级其他人的礼物(即使当前登录用户没有向他们发送该礼物),方法是使用inputInvoiceStarGiftPrepaidUpgrade,传递礼物发送的对等方和来自messageActionStarGiftprepaid_upgrade_hash或savedStarGift的升级哈希。prepaid_upgrade_hash
然后,按照通常的支付流程进行»。
完成后,将发出一条新的messageActionStarGift 消息upgrade_separate,并设置标志,该标志填充消息gift_msg_id的 ID,其中升级后的礼物仅对消息的接收者有效。
分享和获取有关收藏礼品的信息
starGiftUnique#1befe865 flags:# require_premium:flags.6?true resale_ton_only:flags.7?true theme_available:flags.9?true id:long gift_id:long title:string slug:string num:int owner_id:flags.0?Peer owner_name:flags.1?string owner_address:flags.2?string attributes:Vector<StarGiftAttribute> availability_issued:int availability_total:int gift_address:flags.3?string resell_amount:flags.4?Vector<StarsAmount> released_by:flags.5?Peer value_amount:flags.8?long value_currency:flags.8?string theme_peer:flags.10?Peer = StarGift;payments.uniqueStarGift#416c56e8 gift:StarGift chats:Vector<Chat> users:Vector<User> = payments.UniqueStarGift;payments.uniqueStarGiftValueInfo#512fe446 flags:# last_sale_on_fragment:flags.1?true value_is_average:flags.6?true currency:string value:long initial_sale_date:int initial_sale_stars:long initial_sale_price:long last_sale_date:flags.0?int last_sale_price:flags.0?long floor_price:flags.2?long average_price:flags.3?long listed_count:flags.4?int fragment_listed_count:flags.5?int fragment_listed_url:flags.5?string = payments.UniqueStarGiftValueInfo;---functions---payments.getUniqueStarGift#a1974d72 slug:string = payments.UniqueStarGift; payments.getUniqueStarGiftValueInfo#4365af6b slug:string = payments.UniqueStarGiftValueInfo;
可以通过创建收藏礼物链接来分享有关独特礼物的信息»使用starGiftUnique中的 slug。slug
解析收到的收藏品礼品链接时,调用payments.getUniqueStarGift获取有关礼品的信息。
在购买二手礼品时,也可以使用“slug”这个词。
在 API 中任何接受InputSavedStarGift的地方,也可以使用已拥有收藏品礼品链接的 slug ,并传递inputSavedStarGiftSlug。
payments.getUniqueStarGiftValueInfo也可用于获取有关收藏礼品价值的信息。
转售收藏礼品
messageActionStarGiftUnique#34f762f3 flags:# upgrade:flags.0?true transferred:flags.1?true saved:flags.2?true refunded:flags.5?true prepaid_upgrade:flags.11?true gift:StarGift can_export_at:flags.3?int transfer_stars:flags.4?long from_id:flags.6?Peer peer:flags.7?Peer saved_id:flags.7?long resale_amount:flags.8?StarsAmount can_transfer_at:flags.9?int can_resell_at:flags.10?int = MessageAction;inputSavedStarGiftUser#69279795 msg_id:int = InputSavedStarGift; inputSavedStarGiftChat#f101aa7f peer:InputPeer saved_id:long = InputSavedStarGift; inputSavedStarGiftSlug#2085c238 slug:string = InputSavedStarGift;payments.resaleStarGifts#947a12df flags:# count:int gifts:Vector<StarGift> next_offset:flags.0?string attributes:flags.1?Vector<StarGiftAttribute> attributes_hash:flags.1?long chats:Vector<Chat> counters:flags.2?Vector<StarGiftAttributeCounter> users:Vector<User> = payments.ResaleStarGifts;---functions---payments.updateStarGiftPrice#edbe6ccb stargift:InputSavedStarGift resell_amount:StarsAmount = Updates;payments.getResaleStarGifts#7a5fa236 flags:# sort_by_price:flags.1?true sort_by_num:flags.2?true attributes_hash:flags.0?long gift_id:long attributes:flags.3?Vector<StarGiftAttributeId> offset:string limit:int = payments.ResaleStarGifts;
已拥有的收藏礼品»可以通过使用payments.updateStarGiftPrice在礼品市场»上出售,并在其中指定价格。resell_stars
请注意,如果设置了messageActionStarGiftUnique/savedStarGift标志,can_resell_at则礼物只能从指定的日期开始出售。
最低和最高转售价格在客户端配置参数stars_stargift_resale_amount_min »/stars_stargift_resale_amount_max »中指定;传递此参数0会将礼物从市场中移除。
如果有人购买了该礼物,您将获得price*stars_stargift_resale_commission_permille » /1000星。
当以纳吨为单位指定价格时,最低和最高转售价格在客户端配置参数`ton_stargift_resale_amount_min »/ton_stargift_resale_amount_max »`中指定;传递此参数0会将礼物从市场中下架。
如果有人购买了该礼物,您将获得price*`ton_stargift_resale_commission_permille » /1000nanoton`。
使用payments.getStarGifts获取可用starGifts的完整列表;此方法可能会返回一些已售罄的礼物availability_resale,这些礼物带有标记,表示此类礼物正在转售 »,请使用payments.getResaleStarGifts获取它们。
请参阅此处 »获取有关payments.getResaleStarGifts方法的详细文档。
要购买转售礼品,请按照通常的付款流程 »,传递inputInvoiceStarGiftResale。
转让收藏品
messageActionStarGiftUnique#34f762f3 flags:# upgrade:flags.0?true transferred:flags.1?true saved:flags.2?true refunded:flags.5?true prepaid_upgrade:flags.11?true gift:StarGift can_export_at:flags.3?int transfer_stars:flags.4?long from_id:flags.6?Peer peer:flags.7?Peer saved_id:flags.7?long resale_amount:flags.8?StarsAmount can_transfer_at:flags.9?int can_resell_at:flags.10?int = MessageAction;starGiftUnique#1befe865 flags:# require_premium:flags.6?true resale_ton_only:flags.7?true theme_available:flags.9?true id:long gift_id:long title:string slug:string num:int owner_id:flags.0?Peer owner_name:flags.1?string owner_address:flags.2?string attributes:Vector<StarGiftAttribute> availability_issued:int availability_total:int gift_address:flags.3?string resell_amount:flags.4?Vector<StarsAmount> released_by:flags.5?Peer value_amount:flags.8?long value_currency:flags.8?string theme_peer:flags.10?Peer = StarGift;inputSavedStarGiftUser#69279795 msg_id:int = InputSavedStarGift; inputSavedStarGiftChat#f101aa7f peer:InputPeer saved_id:long = InputSavedStarGift; inputSavedStarGiftSlug#2085c238 slug:string = InputSavedStarGift;inputInvoiceStarGiftTransfer#4a5f5bd9 stargift:InputSavedStarGift to_id:InputPeer = InputInvoice;---functions---payments.transferStarGift#7f18176a stargift:InputSavedStarGift to_id:InputPeer = Updates;
收藏品礼品可以转让给其他用户。
要转让收藏品礼物,请通过调用payments.getPaymentForm并传递带有以下参数的inputInvoiceStarGiftTransfer ,向Telegram Stars支付messageActionStarGiftUnique/savedStarGift:transfer_stars
- stargift收到的礼物的标识符
- to_id目标对等体
然后,按照通常的支付流程进行»。
如果messageActionStarGiftUnique/savedStarGift未设置,transfer_stars则可以免费转让礼物:在这种情况下,只需调用payments.transferStarGift即可。
将收藏品礼品提取到 TON 区块链
messageActionStarGiftUnique#34f762f3 flags:# upgrade:flags.0?true transferred:flags.1?true saved:flags.2?true refunded:flags.5?true prepaid_upgrade:flags.11?true gift:StarGift can_export_at:flags.3?int transfer_stars:flags.4?long from_id:flags.6?Peer peer:flags.7?Peer saved_id:flags.7?long resale_amount:flags.8?StarsAmount can_transfer_at:flags.9?int can_resell_at:flags.10?int = MessageAction;savedStarGift#19a9b572 flags:# name_hidden:flags.0?true unsaved:flags.5?true refunded:flags.9?true can_upgrade:flags.10?true pinned_to_top:flags.12?true upgrade_separate:flags.17?true from_id:flags.1?Peer date:int gift:StarGift message:flags.2?TextWithEntities msg_id:flags.3?int saved_id:flags.11?long convert_stars:flags.4?long upgrade_stars:flags.6?long can_export_at:flags.7?int transfer_stars:flags.8?long can_transfer_at:flags.13?int can_resell_at:flags.14?int collection_id:flags.15?Vector<int> prepaid_upgrade_hash:flags.16?string = SavedStarGift;payments.starGiftWithdrawalUrl#84aa3a9c url:string = payments.StarGiftWithdrawalUrl;---functions---payments.getStarGiftWithdrawalUrl#d06e93a8 stargift:InputSavedStarGift password:InputCheckPasswordSRP = payments.StarGiftWithdrawalUrl;
收藏品礼物可以通过使用payments.getStarGiftWithdrawalUrl在 TON 区块链上转换为 NFT:该方法需要当前用户的 2FA 密码,按照此处指定的方式传递 »,并返回一个可用于在 Fragment 上导入 NFT 的 URL。
请注意,如果设置了messageActionStarGiftUnique/savedStarGift标志,can_export_at则礼物只能从指定的日期开始导出到区块链。
将收藏品礼物设置为表情符号状态
已拥有的收藏品礼物 »可以设置为表情符号状态:点击此处 »查看完整流程的更多信息。
将收藏品礼物设置为聊天主题
一些已拥有的收藏礼物 »(带有starGiftUnique.theme_available标志的礼物)可以设置为聊天主题:请参阅此处 »以了解有关完整流程的更多信息。