本文整理汇总了PHP中SaeTClientV2::home_timeline方法的典型用法代码示例。如果您正苦于以下问题:PHP SaeTClientV2::home_timeline方法的具体用法?PHP SaeTClientV2::home_timeline怎么用?PHP SaeTClientV2::home_timeline使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SaeTClientV2
的用法示例。
在下文中一共展示了SaeTClientV2::home_timeline方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: callback
/**
* 从Callback返回时
*/
public function callback()
{
if (isset($_REQUEST['code'])) {
$keys = array();
$keys['code'] = $_REQUEST['code'];
$keys['redirect_uri'] = WB_CALLBACK_URL;
try {
$token = $this->sina->getAccessToken('code', $keys);
} catch (OAuthException $e) {
}
}
if ($token) {
$_SESSION['token'] = $token;
setcookie('weibojs_' . $this->sina->client_id, http_build_query($token));
$c = new SaeTClientV2(WB_AKEY, WB_SKEY, $token['access_token']);
$ms = $c->home_timeline();
// done
$uid_get = $c->get_uid();
$uid = $uid_get['uid'];
$user = $c->show_user_by_id($uid);
//根据ID获取用户等基本信息
$_SESSION['token']['name'] = $user['name'];
echo "\n\t\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\t\twindow.opener.callback_exec('Sina' , {$uid} , '{$user['name']}',false);\n\t\t\t\t\t\twindow.close();\n\t\t\t\t\t</script>";
} else {
echo '授权失败';
}
}
示例2: weibocallback
public function weibocallback($code)
{
$cfg = K::$system->config->get('connect');
if (defined('IN_MOBILE')) {
$mobile = K::$system->config->get('mobile');
$callback = $mobile['url'] . '/' . K::M('helper/link')->mklink('passport:weibocallback');
} else {
$site = K::$system->config->get('site');
$callback = $site['siteurl'] . '/' . K::M('helper/link')->mklink('passport:weibocallback');
}
if (empty($cfg['weibo_is_open'])) {
$this->err->add('很抱歉网站管理员还未开启微博登录功能', 201);
return false;
}
$keys = array();
$keys['code'] = $code;
$keys['redirect_uri'] = $callback;
$o = new SaeTOAuthV2($cfg['weibo_app_id'], $cfg['weibo_app_key']);
try {
$token = $o->getAccessToken('code', $keys);
} catch (OAuthException $e) {
$this->err->add($e->getMessage(), 201);
return false;
}
$c = new SaeTClientV2($cfg['weibo_app_id'], $cfg['weibo_app_key'], $token['access_token']);
$ms = $c->home_timeline();
// done
$uid_get = $c->get_uid();
$uid = $uid_get['uid'];
$user_message = $c->show_user_by_id($uid);
//根据ID获取用户等基本信息
return $this->login($uid, $user_message);
}
示例3: getUserName
private function getUserName()
{
$c = new SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['token']['access_token']);
$ms = $c->home_timeline();
$uid_get = $c->get_uid();
$uid = $uid_get['uid'];
$user_message = $c->show_user_by_id($uid);
return $user_message['screen_name'];
}
示例4: getUser
/**
* 獲取用戶信息
* @param type $access_token
* @return type
* Array ( [id] => 3767777785 [idstr] => 3767777785 [class] => 1
* [screen_name] => soqugame [name] => soqugame
* [province] => 11 [city] => 1 [location] => 北京 东城区 [description] => [url] =>
* [profile_image_url] => http://tp2.sinaimg.cn/3767777785/50/0/1
* [profile_url] => u/3767777785 [domain] => [weihao] => [gender] => m [followers_count] => 3 [friends_count] => 18 [statuses_count] => 0 [favourites_count] => 0 [created_at] => Tue Sep 03 16:48:05 +0800 2013 [following] => [allow_all_act_msg] => [geo_enabled] => 1 [verified] => 1 [verified_type] => 2 [remark] => [ptype] => 0 [allow_all_comment] => 1 [avatar_large] => http://tp2.sinaimg.cn/3767777785/180/0/1 [avatar_hd] => http://tp2.sinaimg.cn/3767777785/180/0/1 [verified_reason] => 上海搜趣广告有限公司 [follow_me] => [online_status] => 0 [bi_followers_count] => 0 [lang] => zh-cn [star] => 0 [mbtype] => 0 [mbrank] => 0 [block_word] => 0 )
*/
public function getUser($access_token)
{
$c = new SaeTClientV2($this->_params['WB_AKEY'], $this->_params['WB_SKEY'], $access_token);
$ms = $c->home_timeline();
// done
$uid_get = $c->get_uid();
$uid = $uid_get['uid'];
$user_message = $c->show_user_by_id($uid);
//根据ID获取用户等基本信息
return $user_message;
}
示例5: getUserInfo
function getUserInfo()
{
require_once dirname(__FILE__) . "/API/saetv2.ex.class.php";
$token = ISession::get('token');
$c = new SaeTClientV2(ISession::get('apiKey'), ISession::get('apiSecret'), $token['access_token']);
$ms = $c->home_timeline();
$uid_get = $c->get_uid();
$uid = $uid_get['uid'];
$user_message = $c->show_user_by_id($uid);
$userInfo = array();
$userInfo['id'] = $uid;
$userInfo['name'] = isset($user_message['screen_name']) ? $user_message['screen_name'] : '';
return $userInfo;
}
示例6: callback
public function callback()
{
$appkey = $this->config->get('weibo_login_appkey');
$appsecret = $this->config->get('weibo_login_appsecret');
$callback_url = $this->url->link('extension/module/weibo_login/callback', '', true);
$this->load->language('extension/module/weibo_login');
$data['text_weibo_login'] = $this->language->get('text_weibo_login');
include_once DIR_SYSTEM . 'library/weibo/saetv2.ex.class.php';
$o = new SaeTOAuthV2($appkey, $appsecret);
if (isset($_REQUEST['code'])) {
$keys = array();
$keys['code'] = $_REQUEST['code'];
$keys['redirect_uri'] = $callback_url;
try {
$token = $o->getAccessToken('code', $keys);
} catch (OAuthException $e) {
}
}
if ($token) {
//setcookie( 'weibojs_'.$o->client_id, http_build_query($token) );
$c = new SaeTClientV2($appkey, $appsecret, $token['access_token']);
$ms = $c->home_timeline();
$uid_get = $c->get_uid();
$uid = $uid_get['uid'];
$user_message = $c->show_user_by_id($uid);
$this->session->data['weibo_login_access_token'] = $token['access_token'];
$this->session->data['weibo_login_uid'] = $uid;
if ($this->customer->login_weibo($this->session->data['weibo_login_access_token'], $this->session->data['weibo_login_uid'])) {
unset($this->session->data['guest']);
// Default Shipping Address
$this->load->model('account/address');
if ($this->config->get('config_tax_customer') == 'payment') {
$this->session->data['payment_address'] = $this->model_account_address->getAddress($this->customer->getAddressId());
}
if ($this->config->get('config_tax_customer') == 'shipping') {
$this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->customer->getAddressId());
}
$this->response->redirect($this->url->link('account/account', '', 'SSL'));
} else {
$this->session->data['weibo_login_warning'] = sprintf($this->language->get('text_weibo_login_warning'), $this->config->get('config_name'));
$this->response->redirect($this->url->link('account/login', '', 'SSL'));
}
} else {
echo $this->language->get('text_weibo_fail');
}
}
示例7: array
function sina_oauth_back()
{
require_once APPPATH . 'libraries/sina/saetv2.ex.class.php';
$o = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
$back_url = base_url() . 'index.php?c=oauth&m=sina_oauth_back';
if (isset($_REQUEST['code'])) {
$keys = array();
$keys['code'] = $_REQUEST['code'];
$keys['redirect_uri'] = $back_url;
try {
$token = $o->getAccessToken('code', $keys);
} catch (OAuthException $e) {
}
}
$c = new SaeTClientV2(WB_AKEY, WB_SKEY, $token['access_token']);
$ms = $c->home_timeline();
// done
$uid_get = $c->get_uid();
$uid = $uid_get['uid'];
$user_message = $c->show_user_by_id($uid);
//根据ID获取用户等基本信息
if ($user_message['gender'] == 'm') {
$user_data['tu_gender'] = 0;
} else {
$user_data['tu_gender'] = 1;
}
$user_data['tu_weibo_nickname'] = $user_message['screen_name'];
$user_data['tu_source'] = 0;
$weibo_user_check = $this->tickets->select('users', $user_data);
if ($weibo_user_check) {
$final_user = $weibo_user_check[0];
} else {
$save_dir = 'api_images';
$image = $user_message['avatar_large'];
$image_new_name = $this->generate_code(10) . '.jpg';
$image = $this->getImage($image, $save_dir, $image_new_name, 1);
$user_data['tu_portrait'] = $image['save_path'];
$user_data['tu_created'] = date('Y-m-d H:i:s');
$result = $this->tickets->insert('users', $user_data);
$temp_user = $this->tickets->select('users', array('tu_id' => $result));
$final_user = $temp_user[0];
}
setcookie('user_cookie', serialize($final_user), time() + 3600 * 24, '/');
redirect('/main/index');
}
示例8: userInfo
function userInfo($token)
{
$c = new SaeTClientV2($this->sina_akey, $this->sina_skey, $token);
$home = $c->home_timeline();
// done
$uid_get = $c->get_uid();
$uid = $uid_get['uid'];
$me = $c->show_user_by_id($uid);
//根据ID获取用户等基本信息
$user['id'] = $me['id'];
$user['type'] = $this->type;
$user['uname'] = $me['name'];
$user['province'] = $me['province'];
$user['city'] = $me['city'];
$user['location'] = $me['location'];
$user['email'] = $me['data']['email'];
$user['userface'] = str_replace($user['id'] . '/50/', $user['id'] . '/180/', $me['profile_image_url']);
$user['sex'] = $me['gender'] == 'm' ? 1 : 0;
return $user;
}
示例9: callback
function callback()
{
import("Org.Util.saetv2");
$o = new \SaeTOAuthV2(WB_AKEY, WB_SKEY);
if (isset($_REQUEST['code'])) {
$keys = array();
$keys['code'] = $_REQUEST['code'];
$keys['redirect_uri'] = WB_CALLBACK_URL;
try {
$token = $o->getAccessToken('code', $keys);
} catch (OAuthException $e) {
}
}
if ($token) {
session("token", $token);
//$_SESSION['token'] = $token
setcookie('weibojs_' . $o->client_id, http_build_query($token));
$c = new \SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['token']['access_token']);
$ms = $c->home_timeline();
// done
$uid_get = $c->get_uid();
$uid = $uid_get['uid'];
$user_message = $c->show_user_by_id($uid);
//根据ID获取用户等基本信息
//var_dump($user_message);die;
session("username", $user_message["screen_name"]);
session("c_img", $user_message["profile_image_url"]);
echo session('username');
?>
success ,<a href="http://www.sutuijian.com">come on</a>
<?php
} else {
?>
default。
<?php
}
}
示例10: callback
public function callback()
{
global_run();
require_once APP_ROOT_PATH . 'system/api_login/sina/saetv2.ex.class.php';
//$sina_keys = es_session::get("sina_keys");
$o = new SaeTOAuthV2($this->api['config']['app_key'], $this->api['config']['app_secret']);
if (isset($_REQUEST['code'])) {
$keys = array();
$keys['code'] = $_REQUEST['code'];
if ($this->api['config']['app_url'] == "") {
$app_url = SITE_DOMAIN . APP_ROOT . "/api_callback.php?c=Sina";
} else {
$app_url = $this->api['config']['app_url'];
}
$keys['redirect_uri'] = $app_url;
try {
$token = $o->getAccessToken('code', $keys);
} catch (OAuthException $e) {
//print_r($e);exit;
showErr("授权失败,错误信息:" . $e->getMessage());
die;
}
}
$c = new SaeTClientV2($this->api['config']['app_key'], $this->api['config']['app_secret'], $token['access_token']);
$ms = $c->home_timeline();
// done
$uid_get = $c->get_uid();
$uid = $uid_get['uid'];
$msg = $c->show_user_by_id($uid);
//根据ID获取用户等基本信息
if (intval($msg['error_code']) != 0) {
showErr("授权失败,错误代码:" . $msg['error_code']);
die;
}
$msg['field'] = 'sina_id';
$msg['sina_token'] = $token['access_token'];
es_session::set("api_user_info", $msg);
if (!$msg['name']) {
app_redirect(url("index"));
exit;
}
//print_r($msg);die();
$user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where sina_id = '" . $msg['id'] . "' and sina_id <> '' and is_effect=1 and is_delete=0");
$is_bind = intval(es_session::get("is_bind"));
if ($user_data) {
$GLOBALS['db']->query("update " . DB_PREFIX . "user set sina_token = '" . $token['access_token'] . "',login_ip = '" . CLIENT_IP . "',login_time= " . NOW_TIME . " where id =" . $user_data['id']);
es_session::delete("api_user_info");
if ($is_bind) {
if (intval($user_data['id']) != intval($GLOBALS['user_info']['id'])) {
showErr("该帐号已经被别的会员绑定过,请直接用帐号登录", 0, url("index", "uc_account"));
} else {
require_once APP_ROOT_PATH . "system/model/user.php";
load_user($user_data['id'], true);
es_session::set("user_info", $user_data);
app_redirect(url("index", "uc_account"));
}
} else {
require_once APP_ROOT_PATH . "system/model/user.php";
auto_do_login_user($user_data['user_name'], $user_data['user_pwd'], $from_cookie = false);
app_redirect(url("index", "index"));
}
} elseif ($is_bind == 1 && $GLOBALS['user_info']) {
//当有用户身份且要求绑定时
$GLOBALS['db']->query("update " . DB_PREFIX . "user set sina_id= '" . $msg['id'] . "', sina_token ='" . $token['access_token'] . "' where id =" . $GLOBALS['user_info']['id']);
require_once APP_ROOT_PATH . "system/model/user.php";
load_user($GLOBALS['user_info']['id'], true);
app_redirect(url("index", "uc_account"));
} else {
$user_info = $this->create_user();
require_once APP_ROOT_PATH . "system/model/user.php";
auto_do_login_user($user_info['user_name'], $user_info['user_pwd'], $from_cookie = false);
app_redirect(url("index", "index"));
}
}
示例11: sendwb
public function sendwb()
{
// 获取消息正文 发晒单 bask 写心情 mood
/*
* if(isset($this->request->post['bask']) && ($this->request->post['bask'])) { $message_text = $this->request->post['bask']; $message_flag = 1; } else if(isset($this->request->post['mood']) && ($this->request->post['mood'])) { $message_text = $this->request->post['mood']; $message_flag = 2; } else { $message_text = ''; $message_flag = 0; } //获取图片url地址 $this->session->data['token'] if(isset($this->request->post['image']) && ($this->request->post['image'])) { $imgurl = $this->request->post['image']; } else { $imgurl = ''; } //获取视频url地址 if(isset($this->reuqest->post['video']) && ($this->request->post['video'])) { $videourl = $this->request->post['video']; } else { $videourl = ''; } //之前已经登录微博并授权 if (isset($_SESSION['token'])) { } //未登录微博授权 else { include_once(DIR_SYSTEM . 'weibo/config.php'); include_once(DIR_SYSTEM . 'weibo/saetv2.ex.class.php'); if (isset($_GET['code'])) { $keys = array(); $keys['code'] = $_GET['code']; $keys['redirect_uri'] = WBS_CALLBACK_URL; try { $token = $o->getAccessToken('code', $keys); } catch (OAuthException $e) { } } else { echo "<script language=\"javascript\">window.open ('https://api.weibo.com/oauth2/authorize?client_id=".WB_AKEY."&redirect_uri=".WBS_CALLBACK_URL."&response_type=code','newwindow','height=440,width=630,top=150,left=300,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no')</script>"; } }
*/
include_once DIR_SYSTEM . 'weibo/config.php';
include_once DIR_SYSTEM . 'weibo/saetv2.ex.class.php';
$o = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
// 之前未登录微博授权
if (isset($_GET['code'])) {
$keys = array();
$keys['code'] = $_GET['code'];
$keys['redirect_uri'] = WBS_CALLBACK_URL;
try {
$token = $o->getAccessToken('code', $keys);
// $this->session->data['token'] = $token;
} catch (OAuthException $e) {
}
}
if (isset($token) && !empty($token)) {
$this->session->data['token'] = $token;
$c = new SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['token']['access_token']);
$ms = $c->home_timeline();
// done
$uid_get = $c->get_uid();
/*
* var_dump($token); var_dump($uid_get);
*/
$uid = $uid_get['uid'];
$user_message = $c->show_user_by_id($uid);
// 根据ID获取用户等基本信息
// 图片微博
if (isset($this->session->data['wb']['imgurl'])) {
$ret = $c->upload($this->session->data['wb']['message_text'] . ' @信恩世通CNstorm', $this->session->data['wb']['imgurl']);
} else {
// 文字微博
$ret = $c->update($this->session->data['wb']['message_text'] . ' @信恩世通CNstorm');
}
// 返回信息
$msg = '';
if (isset($ret['error_code']) && $ret['error_code'] > 0) {
$err = '微博同步失败,';
if ($ret['error_code'] == 20003) {
$msg = $err . "用户不存在";
} elseif ($ret['error_code'] == 20005) {
$msg = $err . "目前仅支持JPG、GIF、PNG的图片";
} elseif ($ret['error_code'] == 20006) {
$msg = $err . "图片太大";
} elseif ($ret['error_code'] == 20012) {
$msg = $err . "输入文字太长,请不要超过140字";
} elseif ($ret['error_code'] == 20015) {
$msg = $err . "账号、IP或应用非法,暂时无法完成此操作";
} elseif ($ret['error_code'] == 20016) {
$msg = $err . "发布内容过于频繁";
} elseif ($ret['error_code'] == 20017) {
$msg = $err . "提交相似的信息";
} elseif ($ret['error_code'] == 20018) {
$msg = $err . "包含非法网址";
} elseif ($ret['error_code'] == 20019) {
$msg = $err . "提交相同的信息";
} elseif ($ret['error_code'] == 20020) {
$msg = $err . "包含广告信息";
} elseif ($ret['error_code'] == 20021) {
$msg = $err . "包含非法内容";
} elseif ($ret['error_code'] == 20022) {
$msg = $err . "此IP地址上的行为异常";
} elseif ($ret['error_code'] == 20032) {
$msg = "发布成功,目前服务器可能会有延迟,请耐心等待1-2分钟";
} else {
$msg = "微博同步失败";
}
} else {
unset($this->session->data['wb']['message_text']);
if (isset($this->session->data['wb']['imgurl'])) {
unset($this->session->data['wb']['imgurl']);
}
$msg = "微博同步成功";
}
echo <<<Eof
<script type="text/javascript">
var i = 3;
function check(){
if(i>0){
i = i - 1;
document.getElementById("time").innerHTML = i;
setTimeout("check()",1000);
}else{
window.opener = null;
window.close();
}
}
setTimeout("check()",1000);
</script>
<body>
<div><p>{$msg}</p></div>
<div>本页面<span id="time">3</span>秒后自动关闭</div>
//.........这里部分代码省略.........
示例12:
<?php
session_start();
include_once 'config.php';
include_once 'saetv2.ex.class.php';
$c = new SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['token']['access_token']);
$c->set_debug(DEBUG_MODE);
$ms = $c->home_timeline();
// done
//var_dump($ms);
$uid_get = $c->get_uid();
$uid = $uid_get['uid'];
$user_message = $c->show_user_by_id($uid);
//根据ID获取用户等基本信息
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新浪微博V2接口演示程序-Powered by Sina App Engine</title>
</head>
<body>
<?php
echo $user_message['screen_name'];
?>
,您好!
<h2 align="left">发送新微博</h2>
<form action="" >
<input type="text" name="text" style="width:300px" />
<input type="submit" />
示例13: public_sina_login
public function public_sina_login()
{
define('WB_AKEY', pc_base::load_config('system', 'sina_akey'));
define('WB_SKEY', pc_base::load_config('system', 'sina_skey'));
define('WEB_CALLBACK', APP_PATH . 'index.php?m=member&c=index&a=public_sina_login&callback=1');
pc_base::load_app_class('saetv2.ex', '', 0);
$this->_session_start();
if (isset($_GET['callback']) && trim($_GET['callback'])) {
$o = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
if (isset($_REQUEST['code'])) {
$keys = array();
$keys['code'] = $_REQUEST['code'];
$keys['redirect_uri'] = WEB_CALLBACK;
try {
$token = $o->getAccessToken('code', $keys);
} catch (OAuthException $e) {
}
}
if ($token) {
$_SESSION['token'] = $token;
}
$c = new SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['token']['access_token']);
$ms = $c->home_timeline();
// done
$uid_get = $c->get_uid();
$uid = $uid_get['uid'];
$me = $c->show_user_by_id($uid);
//根据ID获取用户等基本信息
if (CHARSET != 'utf-8') {
$me['name'] = iconv('utf-8', CHARSET, $me['name']);
$me['location'] = iconv('utf-8', CHARSET, $me['location']);
$me['description'] = iconv('utf-8', CHARSET, $me['description']);
$me['screen_name'] = iconv('utf-8', CHARSET, $me['screen_name']);
}
if (!empty($me['id'])) {
//检查connect会员是否绑定,已绑定直接登录,未绑定提示注册/绑定页面
$where = array('connectid' => $me['id'], 'from' => 'sina');
$r = $this->db->get_one($where);
//connect用户已经绑定本站用户
if (!empty($r)) {
//读取本站用户信息,执行登录操作
$password = $r['password'];
$this->_init_phpsso();
$synloginstr = $this->client->ps_member_synlogin($r['phpssouid']);
$userid = $r['userid'];
$groupid = $r['groupid'];
$username = $r['username'];
$nickname = empty($r['nickname']) ? $username : $r['nickname'];
$this->db->update(array('lastip' => ip(), 'lastdate' => SYS_TIME, 'nickname' => $me['name']), array('userid' => $userid));
if (!$cookietime) {
$get_cookietime = param::get_cookie('cookietime');
}
$_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
$cookietime = $_cookietime ? TIME + $_cookietime : 0;
$phpcms_auth = sys_auth($userid . "\t" . $password, 'ENCODE', get_auth_key('login'));
param::set_cookie('auth', $phpcms_auth, $cookietime);
param::set_cookie('_userid', $userid, $cookietime);
param::set_cookie('_username', $username, $cookietime);
param::set_cookie('_groupid', $groupid, $cookietime);
param::set_cookie('cookietime', $_cookietime, $cookietime);
param::set_cookie('_nickname', $nickname, $cookietime);
$forward = isset($_GET['forward']) && !empty($_GET['forward']) ? $_GET['forward'] : 'index.php?m=member&c=index';
showmessage(L('login_success') . $synloginstr, $forward);
} else {
//弹出绑定注册页面
$_SESSION = array();
$_SESSION['connectid'] = $me['id'];
$_SESSION['from'] = 'sina';
$connect_username = $me['name'];
//加载用户模块配置
$member_setting = getcache('member_setting');
if (!$member_setting['allowregister']) {
showmessage(L('deny_register'), 'index.php?m=member&c=index&a=login');
}
//获取用户siteid
$siteid = isset($_REQUEST['siteid']) && trim($_REQUEST['siteid']) ? intval($_REQUEST['siteid']) : 1;
//过滤非当前站点会员模型
$modellist = getcache('member_model', 'commons');
foreach ($modellist as $k => $v) {
if ($v['siteid'] != $siteid || $v['disabled']) {
unset($modellist[$k]);
}
}
if (empty($modellist)) {
showmessage(L('site_have_no_model') . L('deny_register'), HTTP_REFERER);
}
$modelid = 10;
//设定默认值
if (array_key_exists($modelid, $modellist)) {
//获取会员模型表单
require CACHE_MODEL_PATH . 'member_form.class.php';
$member_form = new member_form($modelid);
$this->db->set_model($modelid);
$forminfos = $forminfos_arr = $member_form->get();
//万能字段过滤
foreach ($forminfos as $field => $info) {
if ($info['isomnipotent']) {
unset($forminfos[$field]);
} else {
if ($info['formtype'] == 'omnipotent') {
//.........这里部分代码省略.........
示例14: getOauthSignup
/**
* Action:OAuth 2.0 Signup
* @return Response
*/
public function getOauthSignup()
{
header("Content-type:text/html;charset=utf-8");
session_start();
include_once app_path('api/weibo/config.php');
include_once app_path('api/weibo/saetv2.ex.class.php');
$o = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
if (isset($_REQUEST['code'])) {
$keys = array();
$keys['code'] = $_REQUEST['code'];
$keys['redirect_uri'] = WB_CALLBACK_URL;
try {
$token = $o->getAccessToken('code', $keys);
} catch (OAuthException $e) {
}
}
if ($token) {
$_SESSION['token'] = $token;
setcookie('weibojs_' . $o->client_id, http_build_query($token));
$c = new SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['token']['access_token']);
$ms = $c->home_timeline();
// Done
$uid_get = $c->get_uid();
$uid = $uid_get['uid'];
$user_message = $c->show_user_by_id($uid);
// Get sinformation according user ID
$nickname = $user_message['screen_name'];
$password = $_SESSION['token']['access_token'];
$credentials = array('email' => $uid, 'password' => $password);
if (Auth::attempt($credentials)) {
// Signin success, redirect to the previous page that was blocked
return Redirect::intended();
} else {
$user = new User();
$user->email = $uid;
$user->password = $_SESSION['token']['access_token'];
$user->nickname = $nickname;
$user->bound_type = '2';
$user->activated_at = date('Y-m-d H:m:s');
$user->save();
return View::make('authority.oauthSuccess');
}
} else {
return View::make('authority.signup')->withErrors(array('add' => '注册失败。'));
}
}
示例15: callback
public function callback()
{
require_once APP_ROOT_PATH . 'system/api_login/sina/saetv2.ex.class.php';
es_session::start();
//$sina_keys = es_session::get("sina_keys");
$o = new SaeTOAuthV2($this->api['config']['app_key'], $this->api['config']['app_secret']);
if (isset($_REQUEST['code'])) {
$keys = array();
$keys['code'] = $_REQUEST['code'];
if ($this->api['config']['app_url'] == "") {
$app_url = SITE_DOMAIN . APP_ROOT . "/api_callback.php?c=Sina";
} else {
$app_url = $this->api['config']['app_url'];
}
$keys['redirect_uri'] = $app_url;
try {
$token = $o->getAccessToken('code', $keys);
} catch (OAuthException $e) {
//print_r($e);exit;
showErr("授权失败,错误信息:" . $e->getMessage());
die;
}
}
$c = new SaeTClientV2($this->api['config']['app_key'], $this->api['config']['app_secret'], $token['access_token']);
$ms = $c->home_timeline();
// done
$uid_get = $c->get_uid();
$uid = $uid_get['uid'];
$msg = $c->show_user_by_id($uid);
//根据ID获取用户等基本信息
if (intval($msg['error_code']) != 0) {
showErr("授权失败,错误代码:" . $msg['error_code']);
die;
}
$msg['field'] = 'sina_id';
$msg['sina_token'] = $token['access_token'];
es_session::set("api_user_info", $msg);
if (!$msg['name']) {
app_redirect(url("index"));
exit;
}
$user_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where sina_id = '" . $msg['id'] . "' and sina_id <> 0");
//print_r($user_data);die();
if ($user_data) {
$user_current_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where id = " . intval($user_data['group_id']));
$user_group = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_group where score <=" . intval($user_data['score']) . " order by score desc");
if ($user_current_group['score'] < $user_group['score']) {
$user_data['group_id'] = intval($user_group['id']);
}
$GLOBALS['db']->query("update " . DB_PREFIX . "user set sina_token = '" . $token['access_token'] . "',login_ip = '" . get_client_ip() . "',login_time= " . get_gmtime() . ",group_id=" . intval($user_data['group_id']) . " where id =" . $user_data['id']);
es_session::delete("api_user_info");
$is_bind = intval(es_session::get("is_bind"));
if ($is_bind) {
if (intval($user_data['id']) != intval($GLOBALS['user_info']['id'])) {
showErr("该帐号已经被别的会员绑定过,请直接用帐号登录", 0, url("shop", "uc_center#setweibo"));
} else {
es_session::set("user_info", $user_data);
app_redirect(url("index", "uc_center#setweibo"));
}
} else {
require_once APP_ROOT_PATH . "system/libs/user.php";
auto_do_login_user($user_data['user_name'], md5($user_data['user_pwd'] . "_EASE_COOKIE"), $from_cookie = false);
app_recirect_preview();
}
} elseif ($is_bind == 1 && $GLOBALS['user_info']) {
//当有用户身份且要求绑定时
$GLOBALS['db']->query("update " . DB_PREFIX . "user set sina_id= '" . intval($msg['id']) . "', sina_token ='" . $token['access_token'] . "' where id =" . $GLOBALS['user_info']['id']);
app_redirect(url("index", "uc_center#setweibo"));
} else {
$this->create_user();
app_redirect(get_gopreview());
}
}