進入短消息中心

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 ['announcepm'] 公共消息數
integer ['systempm'] 系統消息數
返回值 (當 more = 3 時)
含義
array integer [newpm] 未讀消息數
integer ['newprivatepm'] 私人消息數
integer ['announcepm'] 公共消息數
integer ['systempm'] 系統消息數
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 fromuid 發件人用戶 ID,0 為系統消息
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 大於 0:發送成功的最後一條消息 ID
0:發送失敗
-1:超出了24小時最大允許發送短消息數目
-2:不滿足兩次發送短消息最短間隔
-3:不能給非好友批量發送短消息
-4:目前還不能使用發送短消息功能(註冊多少日後才可以使用發短消息限制)

本接口函數用於發送短消息。當 instantly 為 1 時,短消息會直接發送出去,否則本函數會發送一個 header 的 location 請求,使當前頁面跳轉到短消息中心的發送短消息頁面。因此,當 instantly 為 0 時請不要在這個函數運行前後有任何的輸出性的代碼。fromuid 為 0 時為發送系統消息。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 被刪除的短消息數

本接口函數將刪除指定文件夾中的指定消息 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 被刪除的短消息數

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

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

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

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

本接口函數用於標記短消息的已讀/未讀狀態。uids 和 pmids 參數是一個自由 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 時使用
systempm:系統消息,folder 為 inbox 時使用
announcepm:公共消息,folder 為 inbox 時使用
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 uid 用戶 ID
integer pmid 消息 ID
integer touid 消息對方用戶 ID
integer daterange 日期範圍
1:(默認值) 今天
2:昨天
3:前天
4:上周
5:更早
返回值
含義
array 短消息內容數據,其中單條消息數組結構請參看附表

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

獲取單條短消息內容

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

函數參數
參數 含義
integer uid 用戶 ID
integer type 消息的類型
0:(默認值) 獲取指定單條消息
1:獲取指定用戶發的最後單條消息
2:獲取指定用戶收的最後單條消息
integer pmid 消息 ID,默認值 0,type 為 0 時本參數有效
返回值
含義
array 短消息內容數據,其中單條消息數組結構請參看附表

如果 type 為 0,則本接口函數返回指定 pmid 的單條消息內容。如果 type 為 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 ['pmid']消息 ID
string ['msgfrom']發件人用戶名
integer ['msgfromid']發件人用戶 ID
integer ['msgtoid']收件人用戶 ID
integer ['new']1:未讀短消息
0:已讀短消息
string ['subject']標題
integer ['dateline']發送時間的時間戳
string ['message']內容
integer ['daterange']1:今天
2:昨天
3:前天
4:上周
5:更早