联系方式

利用人脉资源。

导入手机联系人

模式:

inputPhoneContact#f392b7f4 client_id:long phone:string first_name:string last_name:string = InputContact;importedContact#c13e3c50 user_id:long client_id:long = ImportedContact; popularContact#5ce14175 client_id:long importers:int = PopularContact;contacts.importedContacts#77d01c3b imported:Vector<ImportedContact> popular_invites:Vector<PopularContact> retry_contacts:Vector<long> users:Vector<User> = contacts.ImportedContacts;---functions---contacts.importContacts#2c800be5 contacts:Vector<InputContact> = contacts.ImportedContacts;

要将本地联系人列表上传到 Telegram 并查看哪些联系人已注册 Telegram,请使用`contacts.importContacts` ,并传递一个包含以下元素的`inputPhoneContact`构造函数数组:

该方法将返回一个contacts.importedContacts构造函数,其中包含以下字段:

将 Telegram 用户添加为联系人

模式:

users.userFull#3b6d152e full_user:UserFull chats:Vector<Chat> users:Vector<User> = users.UserFull;inputUser#f21158c6 user_id:long access_hash:long = InputUser;user#20b1422 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true premium:flags.28?true attach_menu_enabled:flags.29?true flags2:# bot_can_edit:flags2.1?true close_friend:flags2.2?true stories_hidden:flags2.3?true stories_unavailable:flags2.4?true contact_require_premium:flags2.10?true bot_business:flags2.11?true bot_has_main_app:flags2.13?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector<RestrictionReason> bot_inline_placeholder:flags.19?string lang_code:flags.22?string emoji_status:flags.30?EmojiStatus usernames:flags2.0?Vector<Username> stories_max_id:flags2.5?int color:flags2.8?PeerColor profile_color:flags2.9?PeerColor bot_active_users:flags2.12?int bot_verification_icon:flags2.14?long send_paid_messages_stars:flags2.15?long = User;peerSettings#f47741f7 flags:# report_spam:flags.0?true add_contact:flags.1?true block_contact:flags.2?true share_contact:flags.3?true need_contacts_exception:flags.4?true report_geo:flags.5?true autoarchived:flags.7?true invite_members:flags.8?true request_chat_broadcast:flags.10?true business_bot_paused:flags.11?true business_bot_can_reply:flags.12?true geo_distance:flags.6?int request_chat_title:flags.9?string request_chat_date:flags.9?int business_bot_id:flags.13?long business_bot_manage_url:flags.13?string charge_paid_message_stars:flags.14?long registration_month:flags.15?string phone_country:flags.16?string name_change_date:flags.17?int photo_change_date:flags.18?int = PeerSettings;userFull#c577b5ad flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true can_view_revenue:flags2.9?true bot_can_manage_emoji_status:flags2.10?true display_gifts_button:flags2.16?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme:flags.15?ChatTheme private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int stargifts_count:flags2.8?int starref_program:flags2.11?StarRefProgram bot_verification:flags2.12?BotVerification send_paid_messages_stars:flags2.14?long disallowed_gifts:flags2.15?DisallowedGiftsSettings stars_rating:flags2.17?StarsRating stars_my_pending_rating:flags2.18?StarsRating stars_my_pending_rating_date:flags2.18?int main_tab:flags2.20?ProfileTab saved_music:flags2.21?Document = UserFull;updatePeerSettings#6a7e7366 peer:Peer settings:PeerSettings = Update;---functions---users.getFullUser#b60f5918 id:InputUser = users.UserFull;contacts.addContact#e8f463d0 flags:# add_phone_privacy_exception:flags.0?true id:InputUser first_name:string last_name:string phone:string = Updates;

也可以使用contacts.addContact将 Telegram 用户添加到联系人列表(即使我们无法访问他们的电话号码!)。

add_phone_privacy_exception如果我们希望允许其他用户看到我们的电话号码,请设置此标志:如果设置了peerSettings标志,则必须设置此标志(有关更多信息,请参阅操作栏文档 »)。need_contacts_exception

系统会提示其他用户通过“添加联系人”操作栏将我们添加到联系人列表:如果他们接受,他们的电话号码将自动添加到我们的联系人列表中。

分享我们的电话号码

---functions---contacts.acceptContact#f831a20f id:InputUser = Updates;

如果用户点击添加联系人聊天栏中的“添加联系人”按钮,则会调用此方法。

只有当其他用户使用contacts.addContact添加我们为联系人而未使用电话号码,并且没有设置任何,,bar 标志时,该栏才会激活;该标志将被设置,表示我们可以调用contacts.acceptContact与其他用户共享我们的电话号码。add_contactreport_spamblock_contactshare_contact

正在获取联系人列表

模式:

contact#145ade0b user_id:long mutual:Bool = Contact;user#20b1422 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true premium:flags.28?true attach_menu_enabled:flags.29?true flags2:# bot_can_edit:flags2.1?true close_friend:flags2.2?true stories_hidden:flags2.3?true stories_unavailable:flags2.4?true contact_require_premium:flags2.10?true bot_business:flags2.11?true bot_has_main_app:flags2.13?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector<RestrictionReason> bot_inline_placeholder:flags.19?string lang_code:flags.22?string emoji_status:flags.30?EmojiStatus usernames:flags2.0?Vector<Username> stories_max_id:flags2.5?int color:flags2.8?PeerColor profile_color:flags2.9?PeerColor bot_active_users:flags2.12?int bot_verification_icon:flags2.14?long send_paid_messages_stars:flags2.15?long = User;contacts.contacts#eae87e42 contacts:Vector<Contact> saved_count:int users:Vector<User> = contacts.Contacts; contacts.contactsNotModified#b74ba9d2 = contacts.Contacts;savedPhoneContact#1142bd56 phone:string first_name:string last_name:string date:int = SavedContact;---functions---contacts.getContacts#5dd69e12 hash:long = contacts.Contacts;contacts.getSaved#82f1e39f = Vector<SavedContact>;contacts.getContactIDs#7adc669d hash:long = Vector<int>;

使用contacts.getContacts获取联系人列表中所有关联了 Telegram 帐户的成员。

使用contacts.getContactIDs获取所有联系人的 Telegram 用户 ID 数组(如果联系人没有关联的 Telegram 帐户或使用隐私设置隐藏了其帐户,则返回 0)。

要获取完整的联系人列表,包括没有关联 Telegram 帐户的联系人,请将contacts.getSaved与 takeout 会话结合使用»。

获取联系状态

模式:

userStatusEmpty#9d05049 = UserStatus; userStatusOnline#edb93949 expires:int = UserStatus; userStatusOffline#8c703f was_online:int = UserStatus; userStatusRecently#7b197dc8 flags:# by_me:flags.0?true = UserStatus; userStatusLastWeek#541a1d1a flags:# by_me:flags.0?true = UserStatus; userStatusLastMonth#65899777 flags:# by_me:flags.0?true = UserStatus;contactStatus#16d9703b user_id:long status:UserStatus = ContactStatus;---functions---contacts.getStatuses#c4a353ee = Vector<ContactStatus>;

使用contacts.getStatuses获取所有具有可访问 Telegram 帐户的联系人的在线状态。

寻找联系人

模式:

contacts.found#b3134d9d my_results:Vector<Peer> results:Vector<Peer> chats:Vector<Chat> users:Vector<User> = contacts.Found;contacts.sponsoredPeersEmpty#ea32b4b1 = contacts.SponsoredPeers; contacts.sponsoredPeers#eb032884 peers:Vector<SponsoredPeer> chats:Vector<Chat> users:Vector<User> = contacts.SponsoredPeers;---functions---contacts.search#11f812d8 q:string limit:int = contacts.Found;contacts.getSponsoredPeers#b6c8c393 q:string = contacts.SponsoredPeers;

使用contacts.search在联系人列表中进行搜索。

注意:在全局搜索中使用此方法时,还应调用contacts.getSponsoredPeers ,返回一个赞助对等方列表,该列表将显示在contacts.found的结果之后和contacts.foundmy_results的结果之前。:请参阅此处»了解更多信息。results

删除联系人

模式:

---functions---contacts.deleteContacts#96a0e00 id:Vector<InputUser> = Updates;contacts.deleteByPhones#1013fd9e phones:Vector<string> = Bool;contacts.resetSaved#879537f1 = Bool;

使用contacts.deleteContacts删除与 Telegram 帐户关联的联系人;返回的Updates将包含更新后的用户信息。

使用contacts.deleteByPhones可以按电话号码删除联系人,即使他们没有关联的 Telegram 帐户。

使用contacts.resetSaved删除所有未关联 Telegram 帐户的联系人。