/** * 获取未读取数目 * 只有开启了标准版对接功能之后,才有此功能 */ function setUnreadCookie() { $result = array('errno' => 0, 'uid' => XWB_S_UID, 'followers' => 0, 'dm' => 0, 'mentions' => 0, 'comments' => 0, 'allsum' => 0); if (!$this->_checkNextUnreadTime()) { $result['errno'] = -1; } elseif (!XWB_plugin::pCfg('switch_to_xweibo')) { $this->_setNextUnreadCheckTime(); $result['errno'] = -3; } elseif (!XWB_S_UID || !XWB_Plugin::isUserBinded()) { $this->_setNextUnreadCheckTime(); $result['errno'] = -2; } else { $wb = XWB_plugin::getWB(); $wb->is_exit_error = false; $respond = $wb->getUnread(); if (!is_array($respond) || isset($respond['error'])) { $result['errno'] = isset($respond['error']) ? (int) $respond['error'] : -3; } else { $result = array_merge($result, $respond); $this->_setUnreadCookie($result); } $this->_setNextUnreadCheckTime(); } if ($result['errno'] != 0) { header("HTTP/1.1 403 Forbidden"); } echo 'var _xwb_unread_new = ' . json_encode($result) . ';'; exit; }