進入短消息中心

uc_pm_location(integer uid , bool newpm)

函數參數
參數 含義
integer uid 用戶 ID
bool newpm 是否直接查看未讀短消息
1:
0:(默認值)

本接口函數運行後會發送一個 header 的 location 請求,使當前頁面跳轉到短消息中心。所以請不要在這個函數運行前後有任何的輸出性的代碼。如果 newpm 為 1 則進入短消息中心後,會默認打開新件箱。
進入短消息中心示例 (PHP)

檢查新的短消息

bool/array uc_pm_checknew(integer uid [, bool more])

函數參數
參數 含義
integer uid 用戶 ID
bool more 是否顯示更多信息
2:返回短消息數、最後消息時間, 最後消息內容
1:返回短消息數、最後消息時間
0:(默認值) 只返回短消息數
返回值 (當 more = 0 時)
含義
integer 未讀消息數
返回值 (當 more = 1 時)
含義
array integer ['newpm'] 未讀消息數
integer ['newprivatepm'] 私人消息數
返回值 (當 more = 2 時)
含義
array integer ['newpm'] 未讀消息數
integer ['newprivatepm'] 私人消息數
integer ['newchatpm'] 群聊消息數
返回值 (當 more = 3 時)
含義
array integer [newpm] 未讀消息數
integer ['newprivatepm'] 私人消息數
integer ['newchatpm'] 群聊消息數
integer ['lastdate'] 最後消息時間
integer ['lastmsgfromid'] 最後消息發件人 ID
string ['lastmsgfrom'] 最後消息發件人用戶名
string ['lastmsg'] 最後消息內容

本接口函數會檢查指定用戶是否有新的短消息。
檢查新短消息示例 (PHP)

發送短消息

integer uc_pm_send(integer fromuid , string msgto , string subject , string message [, bool instantly , integer replypmid , bool isusername , integer type])

函數參數
參數 含義
integer fromuid 發件人用戶 ID
string msgto 收件人用戶名 / 用戶 ID,多個用逗號分割
string subject 消息標題
string message 消息內容
bool instantly 是否直接發送
1:(默認值) 直接發送消息
0:進入發送短消息的界面
integer replypid 回復的消息 ID
大於 0:回復指定的短消息
0:(默認值) 發送新的短消息
bool isusername msgto 參數是否為用戶名
1:msgto 參數為用戶名
0:(默認值) msgto 參數為用戶 ID
integer type 消息類別
1:群聊消息
0:(默認值)私人消息
返回值
含義
integer 大於 0:發送成功的最後一條消息 ID
0:發送失敗
-1:超過兩人會話的最大上限
-2:超過兩次發送短消息時間間隔
-3:不能給非好友批量發送短消息(已廢棄)
-4:目前還不能使用發送短消息功能(註冊多少日後才可以使用發短消息限制)
-5:超過群聊會話的最大上限
-6:在忽略列表中
-7:超過群聊人數上限
-8:不能給自己發短消息
-9:收件人為空
-10:發起群聊人數小於兩人

本接口函數用於發送短消息。當 instantly 為 1 時,短消息會直接發送出去,否則本函數會發送一個 header 的 location 請求,使當前頁面跳轉到短消息中心的發送短消息頁面。因此,當 instantly 為 0 時請不要在這個函數運行前後有任何的輸出性的代碼。type 為 1 時為發送群聊消息。msgto 默認為用戶 ID,如果要讓用戶名作為參數,可讓 isusername 為 1。replypid 為 0 表示發送的短消息為短消息話題的發起者,如果 replypid 為指定的消息 ID 則表示發送的短消息為回復指定短消息話題的回覆信息。如果 instantly 為 1,那麼發送成功後函數返回發送成功的最後一條消息 ID,返回 0 表示發送失敗。
發送短消息示例 (PHP)

刪除短消息

integer uc_pm_delete(integer uid , string folder , array pmids)

函數參數
參數 含義
integer uid 用戶 ID
string folder 短消息所在的文件夾
inbox:收件箱
outbox:發件箱
array pmids 消息 ID 數組
返回值
含義
integer 1: 刪除成功,0: 刪除失敗

本接口函數將刪除指定文件夾中的指定消息 ID 的短消息。pmids 參數是一個自由 Key 數組類型,如「 array(1, 2, 3, 4, 5 ...) 」,數組的每一個值均為消息 ID。刪除的每一條短消息 UCenter 會進行對方刪除狀態的檢測,如果短消息對方也是刪除狀態,那麼當前消息將在數據庫中刪除,否則只記錄一個刪除標記。
刪除短消息示例 (PHP)

integer uc_pm_deleteuser(integer uid , array touids)

函數參數
參數 含義
integer uid 用戶 ID
array touids 對方用戶 ID 數組
返回值
含義
integer 1: 刪除成功, 0: 刪除失敗

本接口函數將刪除和 uid 對話的 touids 中的所有短消息。

uc_pm_deletechat(integer uid , array plids [, bool type])

函數參數
參數 含義
integer uid 用戶 ID
array plids 要刪除的消息會話 ID 數組
bool type 類別
0:(默認值) 退出群聊
1:刪除群聊

本接口函數用於群聊短消息的退出和刪除。plids 參數是一個自由 Key 數組類型,如「 array(1, 2, 3, 4, 5 ...) 」,數組的每一個值均為 ID。

標記短消息已讀/未讀狀態

uc_pm_readstatus(integer uid , array uids [, array plids, bool status])

函數參數
參數 含義
integer uid 用戶 ID
array uids 要標記的對方用戶 ID 數組
array pmids 要標記的會話 ID 數組,默認值空數組
bool status 要標記的狀態
0:(默認值) 標記為已讀
1:標記為未讀

本接口函數用於標記短消息的已讀/未讀狀態。uids 和 plids 參數是一個自由 Key 數組類型,如「 array(1, 2, 3, 4, 5 ...) 」,數組的每一個值均為 ID。
標記短消息狀態示例 (PHP)

獲取短消息列表

array uc_pm_list(integer uid [, integer page , integer pagesize , string folder , string filter, integer msglen])

函數參數
參數 含義
integer uid 用戶 ID
integer page 當前頁編號,默認值 1
integer pagesize 每頁最大條目數,默認值 10
string folder 短消息所在的文件夾
newbox:新件箱
inbox:(默認值) 收件箱
outbox:發件箱
string filter 過濾方式
newpm:(默認值) 未讀消息,folder 為 inbox 和 outbox 時使用
integer msglen 截取短消息內容文字的長度,0 為不截取,默認值 0
返回值
含義
array integer ['count'] 消息總數
array ['data'] 短消息列表數據,其中單條消息數組結構請參看附表

本接口函數用於獲取指定文件夾的短消息列表。函數已內置分頁,直接通過 page 和 pagesize 即可實現翻頁。

忽略未讀消息提示

uc_pm_ignore(integer uid)

函數參數
參數 含義
integer uid 用戶 ID

本接口函數用於直接忽略未讀短消息的提示狀態。

獲取短消息內容

array uc_pm_view(integer uid , integer pmid [, integer touid , integer daterange , integer page , integer pagesize , integer type , integer isplid])

函數參數
參數 含義
integer uid 用戶 ID
integer pmid 消息 ID
integer touid 消息對方用戶 ID
integer daterange 日期範圍
1:(默認值) 今天
2:昨天
3:前天
4:上周
5:更早
integer page 當前頁碼
integer pagesize 每頁最大條數
integer type 消息類型 1: 私人消息, 2: 群聊消息
integer isplid touid參數是會話id還是用戶id
返回值
含義
array 短消息內容數據,其中單條消息數組結構請參看附表

本接口函數用於返回指定用戶的指定消息 ID 的消息,返回的數據中包含針對這個消息的回復。如果指定 touid 參數,那麼短消息將列出所有 uid 和 touid 之間的短消息,daterange 可以指定返回消息的日期範圍, page 和 pagesize 可以指定返回消息的頁碼和頁面大小。

查找會話消息數量

integer uc_pm_view_num(integer uid , integer touid , bool isplid)

函數參數
參數 含義
integer uid 用戶 ID
integer touid 查找的會話 ID 或者用戶 ID
bool isplid touid參數是會話 ID 還是用戶 ID
返回值
含義
integer 指定會話的消息數量

查找會話消息數量示例 (PHP)

獲取單條短消息內容

integer uc_pm_viewnode(integer uid , integer type , integer pmid)

函數參數
參數 含義
integer uid 用戶 ID
integer type 消息的類型
0: 獲取指定單條消息
integer pmid 消息 ID
返回值
含義
array 短消息內容數據,其中單條消息數組結構請參看附表

查找群聊成員列表

integer uc_pm_chatpmmemberlist(integer uid , integer plid)

函數參數
參數 含義
integer uid 用戶 ID
integer plid 群聊會話 ID
返回值
含義
array 返回群聊的成員列表附表

踢出群聊成員

integer uc_pm_kickchatpm(integer plid , integer uid , integer touid)

函數參數
參數 含義
integer plid 會話 ID
integer uid 用戶 ID
integer touid 踢出的用戶 ID
返回值
含義
integer 1: 踢出成功, 2: 踢出失敗

添加群聊成員

integer uc_pm_appendchatpm(integer plid , integer uid , integer touid)

函數參數
參數 含義
integer plid 會話 ID
integer uid 用戶 ID
integer touid 添加的用戶 ID
返回值
含義
integer 1: 添加成功, 2: 添加失敗

獲取黑名單

string uc_pm_blackls_get(integer uid)

函數參數
參數 含義
integer uid 用戶 ID
返回值
含義
string 黑名單內容數據

本接口函數返回用戶的黑名單設置的內容。
獲取黑名單示例 (PHP)

更新黑名單

bool uc_pm_blackls_set(integer uid , string blackls)

函數參數
參數 含義
integer uid 用戶 ID
string blackls 黑名單內容
返回值
含義
bool 1:更新成功
0:更新失敗

本接口函數用於更新用戶的黑名單列表數據。設置黑名單後,黑名單中的人員將無法發送短消息給 uid 指定的用戶。黑名單中被忽略的人員用用戶名表示,多個忽略人員名單時用逗號 "," 隔開(如:張三,李四,王五),如需禁止所有用戶發來的短消息,請用 "{ALL}" 表示。
更新黑名單示例 (PHP)

添加黑名單項目

bool uc_pm_blackls_add(integer uid , array username)

函數參數
參數 含義
integer uid 用戶 ID
array username 用戶名數組
返回值
含義
bool 1:添加成功
0:添加失敗

本接口函數用於添加用戶的黑名單項目。如需添加屏蔽所有用戶的設置,請讓 username 數組中包含 "{ALL}"
添加黑名單項目示例 (PHP)

刪除黑名單項目

uc_pm_blackls_delete(integer uid , array username)

函數參數
參數 含義
integer uid 用戶 ID
array username 用戶名數組

本接口函數用於刪除用戶的黑名單項目。如需刪除屏蔽所有用戶的設置,請讓 username 數組中包含 "{ALL}"
添加黑名單項目示例 (PHP)

附表:消息列表單條數組結構

integer ['plid']會話 ID
integer ['uid']當前用戶 ID
bool ['isnew']是否未讀標記
integer ['pmnum']該會話相對於當前用戶的消息數量
integer ['lastupdate']當前用戶的最後更新時間
integer ['lastdateline']會話最後更新時間
integer ['authorid']會話發起者 ID
integer ['pmtype']會話類別 1: 私人消息, 2: 群聊消息
string ['subject']標題
integer ['members']會話參與人數
integer ['touid']pmtype參數為1時,該返回值表示對方用戶 ID
string ['tousername']pmtype參數為1時,該返回值表示對方用戶名
integer ['founddateline']會話發起時間
integer ['lastauthorid']會話最後一條的發送人 ID
string ['lastauthor']會話最後一條的發送人用戶名
string ['lastsummary']會話最後一條的發送的內容截取
integer ['pmid'][兼容]消息 ID
integer ['msgfromid'][兼容]發件人用戶 ID
string ['msgfrom'][兼容]發件人用戶名
integer ['msgtoid'][兼容]收件人用戶 ID
integer ['new'][兼容]1:未讀短消息
0:已讀短消息
string ['message'][兼容]內容
integer ['dateline'][兼容]發送時間的時間戳
integer ['daterange'][兼容]1:今天
2:昨天
3:前天
4:上周
5:更早

附表:消息詳細內容單條數組結構

兼容
integer ['pmid']消息 ID
integer ['plid']所屬會話 ID
integer ['authorid']消息發起者 ID
string ['author']消息發起者用戶名
integer ['pmtype']會話類別 1: 私人消息, 2: 群聊消息
string ['subject']標題
integer ['members']會話參與人數
integer ['dateline']消息發起時間
string ['message']消息內容
integer ['founderuid']發起會話的用戶 ID
integer ['founddateline']會話發起時間
integer ['touid']pmtype參數為1時,該返回值表示對方用戶 ID
integer ['msgfromid'][兼容]發件人用戶 ID
string ['msgfrom'][兼容]發件人用戶名
integer ['msgtoid'][兼容]收件人用戶 ID

附表:群聊成員列表單個數組結構

integer ['author']群聊發起者 ID
array ['member']所有成員用戶 ID 列表 如: 「 array(1, 2, 3, ...) 」