本文整理汇总了PHP中XWB_plugin::getWB方法的典型用法代码示例。如果您正苦于以下问题:PHP XWB_plugin::getWB方法的具体用法?PHP XWB_plugin::getWB怎么用?PHP XWB_plugin::getWB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XWB_plugin
的用法示例。
在下文中一共展示了XWB_plugin::getWB方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getSinaUserInfo
/**
* 获取当前授权的单个登录新浪用户资料(保护方法)
*/
function _getSinaUserInfo()
{
$xwb_user = XWB_plugin::getUser();
$sina_id = $xwb_user->getInfo('sina_uid');
if (is_numeric($sina_id) && $sina_id > 0) {
$wb = XWB_plugin::getWB();
$wb->is_exit_error = false;
$this->sina_userinfo = (array) $wb->getUserShow($sina_id);
}
}
示例2: SyncReply
function SyncReply()
{
$sina = jconf::get('sina');
if (!$sina['is_syncreply_tojishigou']) {
return;
}
$tid = max(0, (int) ($this->Post['tid'] ? $this->Post['tid'] : $this->Get['tid']));
if (!$tid) {
return;
}
$info = DB::fetch_first("select * from " . TABLE_PREFIX . "xwb_bind_topic where `tid`='{$tid}'");
if (!$info) {
return;
}
$mid = $info['mid'];
if (!$mid) {
return;
}
if ($sina['syncweibo_tojishigou_time'] > 0 && $info['last_read_time'] + $sina['syncweibo_tojishigou_time'] > time()) {
return;
}
if (!($topic_info = DB::fetch_first("select * from " . TABLE_PREFIX . "topic where `tid`='{$tid}'"))) {
return;
}
$xwb_bind_info = sina_weibo_bind_info($topic_info['uid']);
if (!$xwb_bind_info) {
return;
}
if (!sina_weibo_bind($topic_info['uid'])) {
return;
}
if (!sina_weibo_syncreply_tojishigou($topic_info['uid'])) {
return;
}
if (!$this->MemberHandler->HasPermission('xwb', '__syncreply', 0, $topic_info['uid'])) {
return;
}
if ($this->module_config['oauth2_enable']) {
$p = array('id' => $mid, 'access_token' => $xwb_bind_info['access_token']);
$rets = sina_weibo_api('2/comments/show', $p, 'GET');
$datas = $rets['comments'];
} else {
require_once ROOT_PATH . 'include/ext/xwb/sina.php';
$wb = XWB_plugin::getWB();
$datas = $wb->getComments($mid);
}
if ($datas) {
krsort($datas);
$TopicLogic = jlogic('topic');
foreach ($datas as $data) {
$mid = $data['idstr'] ? $data['idstr'] : ($data['mid'] ? $data['mid'] : $data['id']);
$sina_uid = $data['user']['id'];
if ($mid && ($bind_info = DB::fetch_first("select * from " . TABLE_PREFIX . "xwb_bind_info where `sina_uid`='{$sina_uid}'")) && !DB::fetch_first("select * from " . TABLE_PREFIX . "xwb_bind_topic where `mid`='{$mid}'") && ($content = trim(strip_tags(array_iconv('utf-8', $this->Config['charset'], $data['text'] . (isset($data['retweeted_status']) ? " /" . "/@{$data['retweeted_status']['user']['name']}: {$data['retweeted_status']['text']}" : "")))))) {
DB::query("insert into " . TABLE_PREFIX . "xwb_bind_topic (`mid`) values ('{$mid}')");
$_t = time();
if ($data['created_at']) {
$_t = strtotime($data['created_at']);
}
$_t = is_numeric($_t) ? $_t : 0;
$add_datas = array('totid' => $tid, 'content' => $content, 'from' => 'sina', 'type' => 'reply', 'uid' => $bind_info['uid'], 'timestamp' => $_t);
$add_result = $TopicLogic->Add($add_datas);
if (is_array($add_result) && count($add_result)) {
$_tid = max(0, (int) $add_result['tid']);
if ($_tid) {
if ($sina['is_syncimage_tojishigou'] && $data['original_pic']) {
$TopicLogic->_parse_url_image($add_result, $data['original_pic']);
}
DB::query("replace into " . DB::table('xwb_bind_topic') . " (`tid`, `mid`) values ('{$_tid}', '{$mid}')");
}
}
}
}
}
DB::query("update `" . TABLE_PREFIX . "xwb_bind_topic` set `last_read_time`='" . time() . "' where `tid`='{$tid}'");
}
示例3: sendShare
/**
* 转发主题 For DiscuzX1.5
* @param $message 发布内容
* @param $pic 发布图片
* @return bool
*/
function sendShare($message, $pic = '')
{
if (empty($message)) {
return false;
}
// 转码及过滤UBB与表情
$message = $this->_filter($message);
// 同步到微博
$wb = XWB_plugin::getWB();
$ret = array();
if (!empty($pic)) {
$ret = $wb->upload($message, $pic, null, null, false);
if (isset($ret['error_code']) && 400 == (int) $ret['error_code']) {
$ret = $wb->update($message, false);
}
} else {
$ret = $wb->update($message, false);
}
return $ret;
}
示例4: _getUserInfo
/**
* 获取用户信息
* @return array $rst 用户信息
*/
function _getUserInfo()
{
/* 获取绑定信息 */
$sina_id = XWB_plugin::getBindInfo('sina_uid');
if (!$sina_id) {
return array('error_no' => '10001', 'error' => '错误:用户未绑定.');
}
/* 获取用户资料 */
$wbApi = XWB_plugin::getWB();
$keys = $this->_getTockenFromDB($sina_id);
if (empty($keys)) {
return array('error_no' => '10002', 'error' => '错误:无法获取绑定信息.');
}
$wbApi->setTempToken($keys['oauth_token'], $keys['oauth_token_secret']);
$wbApi->is_exit_error = false;
$rst = $wbApi->getUserShow($sina_id);
if (!is_array($rst) || isset($rst['error']) || empty($rst['id'])) {
return array('error_no' => '10003', 'error' => "错误:无法从接口中获取用户信息.");
}
return $rst;
}
示例5: setUnreadCookie
/**
* 获取未读取数目
* 只有开启了标准版对接功能之后,才有此功能
*/
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;
}
示例6: _getOAuthUrl
function _getOAuthUrl()
{
static $aurl = null;
if (!empty($aurl)) {
return $aurl;
}
$sess = XWB_plugin::getUser();
$sess->clearToken();
$wbApi = XWB_plugin::getWB();
$keys = $wbApi->getRequestToken();
if (!isset($keys['oauth_token']) || !isset($keys['oauth_token_secret'])) {
$api_error_origin = isset($keys['error']) ? $keys['error'] : 'UNKNOWN ERROR. MAYBE SERVER CAN NOT CONNECT TO SINA API SERVER';
$api_error = isset($keys['error_CN']) && !empty($keys['error_CN']) && 'null' != $keys['error_CN'] ? $keys['error_CN'] : '';
XWB_plugin::LOG("[WEIBO CLASS]\t[ERROR]\t#{$wbApi->req_error_count}\t{$api_error}\t{$wbApi->last_req_url}\tERROR ARRAY:\r\n" . print_r($keys, 1));
XWB_plugin::showError("服务器获取Request Token失败;请稍候再试。<br />错误原因:{$api_error}[{$api_error_origin}]");
}
//print_r($keys);
$aurl = $wbApi->getAuthorizeURL($keys['oauth_token'], false, XWB_plugin::getEntryURL('xwbAuth.authCallBack'));
$sess->setOAuthKey($keys, false);
return rtrim($aurl, '&');
}
示例7: shareCommentSync
/**
* 分享评论同步
* @param int $id 分享id
* @param string $message 内容
*/
function shareCommentSync($id, $message)
{
global $_G;
$mid = $this->isSync($id, 'share');
if (!$mid || !XWB_plugin::isUserBinded()) {
return;
}
$message = $this->_convert($message);
$link = ' ' . $_G['siteurl'] . "home.php?mod=space&do=share&id={$id}";
if (1 == XWB_plugin::pcfg('link_visit_promotion')) {
$link .= '&fromuid=' . $_G['uid'];
}
$length = 140 - ceil(strlen(urlencode($link)) * 0.5);
//2个字母为1个字
$message = $this->_substr($message, $length);
$message .= $link;
//同步到微博
$wb = XWB_plugin::getWB();
$rs = $wb->comment($mid, $message, null, false);
}