Tencent://Message/協議


騰訊官方通過 Tencent://Message/協議可以讓QQ用戶顯示QQ/TM的在線狀態發布在互聯網上;並且點擊 XXX ,不用加好友也可以聊天
官方鏈接: http://is.qq.com/webpresence/code.shtml

具體代碼:
| < 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_ROOT\TENCENT] @=”TencentProtocol” “URL Protocol”=”D:\Program Files\Tencent\QQ\Timwp.exe” |
| [HKEY_CLASSES_ROOT\TENCENT\DefaultIcon] @=”D:\Program Files\Tencent\QQ\Timwp.exe,1″ |
| [HKEY_CLASSES_ROOT\TENCENT\shell] |
| [HKEY_CLASSES_ROOT\TENCENT\shell\open] |
| [HKEY_CLASSES_ROOT\TENCENT\shell\open\command] @=”\”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_ROOT\foo] @="URL:foo Protocol" "URL Protocol"="" |
| [HKEY_CLASSES_ROOT\foo\shell] |
| [HKEY_CLASSES_ROOT\foo\shell\open] |
| [HKEY_CLASSES_ROOT\foo\shell\open\command] @=""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 Files\Application\program.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 |


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM