public function oauth() {
			pc_base::load_plugin_class('weibooauth','',0);
			$setting = getcache('weibo_var','plugins');			
			if(!isset($_REQUEST['oauth_verifier']) || $_REQUEST['oauth_verifier'] == '') {
				if($this->auth_db->get_one(array('source'=>'sina'))) {
					$txt = '授权成功,<a href="?m=zl_admin&c=plugin&a=config&pluginid='.$this->pluginid.'&module=removeauth&pc_hash='.$_SESSION['pc_hash'].'">解除绑定</a>';
				} else {
					$o = new WeiboOAuth( $setting['wb_akey'] , $setting['wb_skey']);
					$keys = $o->getRequestToken();
					print_r($keys);
					$aurl = $o->getAuthorizeURL( $keys['oauth_token'] ,false , get_url());
					$_SESSION['keys'] = $keys;
					$txt = '<a href="'.$aurl.'">点击进行授权</a>';
				}
				
			} else {
				$o = new WeiboOAuth( $setting['wb_akey'] , $setting['wb_skey'] , $_SESSION['keys']['oauth_token'] , $_SESSION['keys']['oauth_token_secret']  );
				$last_key = $o->getAccessToken(  $_REQUEST['oauth_verifier'] ) ;				
				$c = new WeiboClient( $setting['wb_akey'] , $setting['wb_skey'] , $last_key['oauth_token'] , $last_key['oauth_token_secret']  );
				$ms  = $c->home_timeline(); // done
				$me = $c->verify_credentials();	
				$this->auth_db->insert(array('uid'=>$me['id'],'token'=>$last_key['oauth_token'],'tsecret'=>$last_key['oauth_token_secret'],'source'=>'sina'));
				$txt = '授权成功,'.$me['name'].'<a href="?m=zl_admin&c=plugin&a=config&pluginid='.$this->pluginid.'&module=removeauth&pc_hash='.$_SESSION['pc_hash'].'">解除绑定</a>';
			}
			include $this->op->plugin_tpl('oauth',PLUGIN_ID);
		}
Example #2
0
 function getUserInfo()
 {
     $c = new WeiboClient(ISession::get('apiKey'), ISession::get('apiSecret'), $_SESSION['last_key']['oauth_token'], $_SESSION['last_key']['oauth_token_secret']);
     $ms = $c->home_timeline();
     $me = $c->verify_credentials();
     $userInfo = array();
     $userInfo['id'] = isset($me['id']) ? $me['id'] : '';
     $userInfo['name'] = isset($me['name']) ? $me['name'] : '';
     return $userInfo;
 }
Example #3
0
<?php

session_start();
include_once 'config.php';
include_once 'weibooauth.php';
$c = new WeiboClient(WB_AKEY, WB_SKEY, $_SESSION['last_key']['oauth_token'], $_SESSION['last_key']['oauth_token_secret']);
$ms = $c->home_timeline();
// done
$me = $c->verify_credentials();
?>
<h2><?php 
echo $me['name'];
?>
 你好~ 要换头像么?</h2>
<form action="weibolist.php" >
<input type="text" name="avatar" style="width:300px" value="头像url" />
&nbsp;<input type="submit" />
</form>
<h2>发送新微博</h2>
<form action="weibolist.php" >
<input type="text" name="text" style="width:300px" />
&nbsp;<input type="submit" />
</form>

<h2>发送图片微博</h2>
<form action="weibolist.php" >
<input type="text" name="text" style="width:300px" value="文字内容" />
<input type="text" name="pic" style="width:300px" value="图片url" />
&nbsp;<input type="submit" />
</form>
<?php 
Example #4
0
<?php
ini_set('display_errors', true);
require_once( dirname(dirname(dirname(__FILE__))) . '/app.php');
require_once( 'config.php' );
require_once( 'txwboauth.php' );
require_once( 'class.krumo.php' );

$c = new WeiboClient( WB_AKEY , WB_SKEY , $_SESSION['last_key']['oauth_token'] , $_SESSION['last_key']['oauth_token_secret']  );
$ms  = $c->home_timeline();// done
$me  = $c->user_info(); 

var_dump($me);

if ( $_POST ) {
	$u = array();
	$u['username'] = strval($_POST['username']);
	$u['password'] = strval($_POST['password']);
	$u['email'] = strval($_POST['email']);
	$u['city_id'] = isset($_POST['city_id']) 
		? abs(intval($_POST['city_id'])) : abs(intval($city['id']));
	$u['mobile'] = strval($_POST['mobile']);

	if ( $_POST['subscribe'] ) { 
		ZSubscribe::Create($u['email'], abs(intval($u['city_id']))); 
	}
	if ( ! Utility::ValidEmail($u['email'], true) ) {
		Session::Set('error', 'Email地址为无效地址');
		redirect( WEB_ROOT . 'signup.php');
	}
	if ( $_POST['password']) {
		if ( option_yes('emailverify') ) { 
 public function opscallback()
 {
     if (isset($_REQUEST['oauth_verifier'])) {
         //var_dump($_SESSION["app_key"]);
         $o = new WeiboOAuth($_SESSION['app_key'], $_SESSION['app_secret'], $_SESSION['keys']['oauth_token'], $_SESSION['keys']['oauth_token_secret']);
         //$o = new WeiboOAuth('11111','11111',$_SESSION['keys']['oauth_token'],$_SESSION['keys']['oauth_token_secret']);
         $last_key = $o->getAccessToken($_REQUEST['oauth_verifier']);
         if (empty($last_key['error_code'])) {
             //var_dump($last_key);
             $c = new WeiboClient($_SESSION['app_key'], $_SESSION['app_secret'], $last_key['oauth_token'], $last_key['oauth_token_secret']);
             //var_dump($c);
             $ms = $c->home_timeline();
             // done
             $me = $c->verify_credentials();
             //var_dump($me);
             $ot_info = array('operator_id' => 0, 'email' => $me['name'], 'account' => $me['id'], 'oauth_token' => $last_key['oauth_token'], 'oauth_token_secret' => $last_key['oauth_token_secret'], 'type' => 'weibo_op');
             $ever_list = $this->SynchroOperator->find('first', array('conditions' => array('SynchroOperator.account' => $me['id'], 'SynchroOperator.type' => 'weibo_op')));
             if (empty($ever_list)) {
                 $this->SynchroOperator->deleteAll(array('SynchroOperator.type' => 'weibo_op'));
                 $this->SynchroOperator->save($ot_info);
             } else {
                 $this->SynchroOperator->updateAll(array('SynchroOperator.oauth_token' => $last_key['oauth_token'], 'SynchroOperator.oauth_token_secret'), array('SynchroOperator.account' => $me['id']));
             }
             $app_foo = $this->Application->find('first', array('conditions' => array('Application.code' => 'APP-WEIBO'), 'fields' => array('Application.id')), false);
             $this->redirect('/applications/view/' . $app_foo['Application']['id']);
         }
     }
     $msg = $this->ld['sina_interface_abnormal'];
     echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script type="text/javascript">alert("' . $msg . '");	window.location.href="/pages/home"</script>';
     die;
 }