Tencent://Message/协议的实现原理

摘要:
P=1:215555521:3'alt=“单击此处向我发送消息”˃但是它是如何工作的?以下文章和微软官方描述详细解释了其工作原理:微软官方描述:http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/pluggable/overview/appendix_a.aspRegisterprotocol本文描述如何为Windows、Linux和OSX操作系统注册协议。例如,Windows实际上只需要写入注册表即可实现协议和执行程序之间的关联。例如,腾讯的Tencent://Message协议注册表如下:[HKEY_CLASSES_ROOTTENCENT]@=“TenantProtocol”“URLProtocol”=“D:ProgramFiles Tenant QQ Timwp.exe”[HKEY-CLASSES_ROOTTENCENTDefaultIcon]@=”D:Program Files Tentnt QQ Timwp..exe“exe,1”[HKAY_CLASES_ROOTTENCENTshell][HKEY_CLASSE_ROOTTENTshellopen][HKDY_CLASSES_ROOTTENCENTshellopencommand]@=“”D:\ProgramFiles\Tencent\QQQQ\Timwp。Exe“%1”此注册表的作用是自动调用Timwp。当浏览器(或其他)遇到tencent://...,并通过tencent://...Timwp的地址。exe作为第一个参数。

腾讯官方通过 Tencent://Message/协议可以让QQ用户显示QQ/TM的在线状态发布在互联网上;并且点击 XXX ,不用加好友也可以聊天

官方链接: http://is.qq.com/webpresence/code.shtml

具体代码:
<a href="http://t.zoukankan.com/tencent://message/?uin=215555521&Site=JooIT.com&Menu=yes"> < img border="0" SRC='http://wpa.qq.com/pa?p=1:215555521:3' alt="点击这里给我发消息"> < /a>

但它是如何实现的呢?下面文章以及微软官方说明详细解释了其工作原理:


微软官方说明:http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/pluggable/overview/appendix_a.asp

Register protocol,此文中对于 Windows、Linux 和 OS X 操作系统如何注册协议都有说明。比如说 Windows,其实只需写入注册表,即可实现协议与执行程序的关联。例如腾讯的Tencent://Message协议注册表如下:
[HKEY_CLASSES_ROOTTENCENT] @=”TencentProtocol” “URL Protocol”=”D:\Program Files\Tencent\QQ\Timwp.exe”
[HKEY_CLASSES_ROOTTENCENTDefaultIcon] @=”D:\Program Files\Tencent\QQ\Timwp.exe,1″
[HKEY_CLASSES_ROOTTENCENTshell]
[HKEY_CLASSES_ROOTTENCENTshellopen]
[HKEY_CLASSES_ROOTTENCENTshellopencommand] @=””D:\Program Files\Tencent\QQ\Timwp.exe” ”%1”"
此注册表所实现的就是当浏览器(或其它)碰到 tencent://… 时,自动调用 Timwp.exe,并把 tencent://… 地址作为第一个参数传递给 Timwp.exe。
更多参见:Registering an Application to a URL Protocol
附:原文

程序代码:
A protocol is a method that is used to send, receive, and handle information over a connection. Common protocols viewed from the browser include http, ftp, and mailto. In order for you to view information sent over a specific protocol, it must be registered. Once registered, the protocol can then be handled by the program you specify, such as your browser or a 3rd party viewer. This means that a hyperlink ( e.g. foo://fred ) can use the handler for protocol foo to open the file named fred.
Contents [hide] 1 Registering an unsupported protocol 1.1 Windows 1.2 Linux 1.3 OS X 2 Redirecting a registered protocol
[edit]Registering an unsupported protocol Mozilla products utilize protocols defined internally, as well as those defined by the operating system. You can add the ability to use an unsupported protocol by registering it. The OS-specific method of doing this is described below.
[edit]Windows Create the registry .reg file, replacing foo with your unregistered protocol, and the path with whatever handler program you want to run. Then merge it into the Windows registry.
REGEDIT4
[HKEY_CLASSES_ROOTfoo] @="URL:foo Protocol" "URL Protocol"=""
[HKEY_CLASSES_ROOTfooshell]
[HKEY_CLASSES_ROOTfooshellopen]
[HKEY_CLASSES_ROOTfooshellopencommand] @=""C:\Program Files\Application\program.exe" "%1"" See Registering an Application to a URL Protocol for additional information.
[edit]Linux Registration is unnecessary. Simply associate whatever proto: with a program through Firefox: Example: Add the sip: protocol to launch kphone for VoIP calls in Firefox:
- Type about:config into the address bar - Right-click create new boolean value: network.protocol-handler.external.sip and set to true - Right-click create new boolean value: network.protocol-handler.warn-external.sip and set to false - Right-click create new string value: network.protocol-handler.app.sip and set to /usr/bin/kphone This will actually launch kphone. Not sure if it will dial though. That is untested :)
You can also optionally register the protocol with whatever window manager you are using. In KDE this is done through Control Center - KDE Components - File Associations. This step is usually unnecessary unless your window manager has a custom browser, such as konqueror.
[edit]OS X Probably very similar to Linux (above).
[edit]Redirecting a registered protocol If the protocol is already handled by the browser, you can specify what program will be used as a handler to open the file. To do this, add the pref: network.protocol-handler.app.foo as a string with value C:Program FilesApplicationprogram.exe Note: If the path or name is incorrect, the browser will display an error saying "protocol (foo) isn't associated with any program". (See bug 312953).
You may also need to use the following prefs, although this is uncertain: network.protocol-handler.external.foo = true network.protocol-handler.expose.foo = false

免责声明:文章转载自《Tencent://Message/协议的实现原理》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇[转载]目前流行的缺陷管理工具房子楼层下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

国内云存储对比: 阿里云、腾讯云、Ucloud、首都在线

阿里云的数据存储<http://www.aliyun.com/product/rds/> RDS — 关系型数据库服务(Relational Database Service,简称RDS)是一种即开即用、稳定可靠、可弹性伸缩的在线数据库服务。具有多重安全防护措施和完善的性能监控体系,并提供专业的数据库备份、恢复及优化方案,使您能专注于应用开发...

腾讯QQ的历史

http://www.agenow.com/bbs/DispText.aspx?id=1385106 OICQ:   大家都习惯性的认为OICQ是马化腾先生自己动手研发的,可在腾讯内部的网友之间又传来另一个版本的QQ故事。“你看马化腾哪点象做程序的?”这是当时有一个资深的网友对我说的话。一句无心的话,却勾起了我的好奇心,“这QQ到底是谁做的?”打探之下我...

微信小程序腾讯云配置Tomcat https端口

在个人开发微信小程序时,发布之前要配置微信小程序的域名https及域名的SSL证书的申请及安装 我用的是腾讯云,SSL证书申请好之后,点击下载,解压文件夹,会有如图,根据你要配置的服务器是哪种,我是tomcat配置,这时候腾讯云官方有文档,教你4种不同该怎么去云服务器配置,一步步跟着走就行。一般配置完成后会发现,还是运行不了https的网址,我个人用配置T...

【腾讯Bugly干货分享】微信小程序开发思考总结——腾讯“信用卡还款”项目实践

本文来自于腾讯bugly开发者社区,未经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/58212d0fa7a7574c4f4cc3c5 作者:peggy 小程序概述 11月3日晚,微信团队对外宣布,微信小程序开放公测。开发者可登陆微信公众平台申请,开发完成后可以提交审核,公测期间暂不能发布。 我们前一段时间也进行了小程序开发...

腾讯云分布式数据库TDSQL再获认可

2021年8月17-18日2021第四届中国保险大数据分析与人工智能创新国际峰会隆重举办,并公布IIC 2021年度“保险创新者大奖”评选结果。 IIC年度“保险创新者大奖”由企业自主申报,经来自行业协会、产业联盟、媒体及咨询公司等机构的各方专业人士组成的评审委员会评议和投票,经过激烈的角逐,15家企业入围IIC年度“保险创新者大奖”。腾讯云分布式数据库...

如何查看别人公众号的粉丝量

想要查看查看别人公众号的粉丝数量,这个是管理员才能做到的; 但可以通过其它途径,查询到一部分分公众号的粉丝量信息。 方法一:借助媒体平台: 1、 西瓜数据:http://data.xiguaji.com/Home/guideadv2?chl=baiduapaihangbang&renqun_youhua=734849 2、 微小宝:https:/...