博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

飞信协议中的扩展方法(转)

Posted on 2009-03-05 02:52  走来走去  阅读(645)  评论(0编辑  收藏  举报

 wireshark filter为:tcp port 8080 and host 221.130.45.203

飞信协议中的扩展方法

Service方法(S),是IETF定义的一个SIP扩展方法,用来向SIP服务器请求额外的服务。

协议中,现发现的所有部分,凡是要用到字符串的,统一都是用UTF-8。

1、心情短语

(1)获取

S fetion.com.cn SIP-C/2.0

F: 123456789

I: 2

Q: 1 S

N: GetPersonalInfo

L: 172

<args><personal version=”11″ attributes=”all” /><services version=”11″ attributes=”all” /><config version=”109″ attributes=”all” /><mobile-device attributes=”all” /></args>

(2)设置

S fetion.com.cn SIP-C/2.0

F: 123456789

I: 47

Q: 1 S

N: SetPersonalInfo

L: 48

<args><personal impresa=”" /></args>

服务器返回:

SIP-C/2.0 200 OK

I: 47

Q: 1 S

L: 67

<results><personal version=”14″ impresa=”" /></results>

每设置一次,version号就会增加一个。

2、获取好友列表中的好友信息

S fetion.com.cn SIP-C/2.0

F: 123456789

I: 16

Q: 1 S

N: GetContactsInfo

L: 137

<args><contacts attributes=”all” extended-attributes=”score-level”><contact uri=”sip:584773816@fetion.com.cn;p=4019″ /></contacts></args>

如果成功,服务器将会返回

<results><contacts><contact uri=”sip:584773816@fetion.com.cn;p=4019″><extended score-level=”2″/></contact></contacts></results>

以及:

<events><event type=”ServiceResult”><results><contacts><contact uri=”sip:584773816@fetion.com.cn;p=1755″ status-code=”200″><personal version=”19″ nickname=”" gender=”2″ impresa=”" nation=”CN” province=”js” city=”516″ ivr-enabled=”1″ portrait-crc=”1514698093″ provisioning=”1″ mobile-no=”13985478528″ name=”" birth-date=”1985-01-01″ birthday-valid=”0″ lunar-animal=”1″ horoscope=”1″ profile=”" blood-type=”2″ occupation=”" hobby=”" personal-email=”" work-email=”" other-email=”" primary-email=”0″/></contact></contacts></results></event></events>

GetPresence

<args><query><contacts><contact uri=”sip:584773816@fetion.com.cn;p=4019″ /></contacts><presence><extended types=”mobile-device-status” /></presence></query></args>

3、联系权限(是否公开手机号)

分两个,get(设置自己对别人的)和set(获取别人对自己的)

(1)SetContactPermission

发送:SetContactPermission

<args>

<permissions>

<permission uri=”sip:584677816@fetion.com.cn;p=5075″ values=”identity=0″ />

</permissions>

</args>

收到:

<results><permissions version=”68″><permission uri=”sip:584677816@fetion.com.cn;p=5075″ values=”identity=0;”/></permissions></results>

(2)GetContactPermission

发送:

<args><permissions all=”0″ objects=”all”><permission uri=”sip:584677816@fetion.com.cn;p=4019″ /></permissions></args>

服务器返回:

<results><permissions><permission uri=”sip:584773816@fetion.com.cn;p=4019″ values=”identity=1;”/></permissions></results>

4、给自己发短信。

这个算是飞信比较新的功能吧。格式也有些奇怪。

头是这样的:

M fetion.com.cn SIP-C/2.0

F: 584677816

I: 51

Q: 1 M

T: sip:573435199@fetion.com.cn;p=668

N: SendCatSMS

L: 9

正文不是XML。正文直接就是要发送的短信的内容。(注意,UTF-8编码)

如果成功,服务器会返回:

SIP-C/2.0 280 Send SMS OK

T: sip:584677816@fetion.com.cn;p=668

I: 51

Q: 1 M

D: Wed, 02 Apr 2008 17:01:14 GMT

XI: cfdd2e042cee434eba0bad035c8ff8ed

最末那个XI字段不知道是做什么用的。

注:(从别人那里抄来的)

p=手机号码前6位 - 134099

缩写对应表:

Authorization    缩写为”A”

CallID        “I”

Contact        “M”

ContentEncoding    “E”

ContentLength    “L”

ContentType    “C”

CSeq        “Q”

Date        “D”

EndPoints    “EP”

Event        “N”

Expires        “X”

From        “F”

MessageID    “XI”

ReferredBy    “RB”

ReferTo        “RT”

Require        “RQ”

RosterManager    “RM”

Source        “SO”

Supported    “K”

To        “T”

Unsupported    “UK”

WWWAuthenticate    “W”