コード例 #1
0
ファイル: tqq.php プロジェクト: yunsite/snshub
 function callback()
 {
     //var_dump($_REQUEST);
     //这个key就是这个用户的令牌,很NB,要好好保存
     $callback = site_url() . '/binding/tqq/callback';
     //var_dump($this->session);
     $o = new MBOpenTOAuth(MB_AKEY, MB_SKEY, $this->session->userdata('oauth_token'), $this->session->userdata('oauth_token_secret'));
     $result = $o->getAccessToken($_REQUEST['oauth_verifier']);
     //获取ACCESSTOKEN
     //var_dump($result);
     $sns_oauth_token = $result['oauth_token'];
     $sns_oauth_token_secret = $result['oauth_token_secret'];
     $sns_uid = $result['name'];
     //让人吃金啊
     if (empty($sns_uid)) {
         throw new Exception('oauth fail, havnt got getAccessToken()');
     }
     //获取用户信息
     //$c = new WeiboClient( WB_AKEY , WB_SKEY , $sns_oauth_token , $sns_oauth_token_secret);
     $c = new MBApiClient(MB_AKEY, MB_SKEY, $sns_oauth_token, $sns_oauth_token_secret);
     $me = $c->getUserInfo();
     $me = $me['data'];
     //把资料准备好之后,剩下的就交给父类里的模版方法了!
     parent::post_login(UserManager::sns_website_tqq, $sns_uid, $sns_oauth_token, $sns_oauth_token_secret, $me['name']);
     /*
     $binding = $this->usermanager->get_binding_by_sns_uid(UserManager::sns_website_tqq, $sns_uid);
     if(empty($binding))
     {
     	//初次登录用户
     	//创建用户(同时创建sns_binding)
     	$user = $this->usermanager->create_user(UserManager::sns_website_tqq, $sns_uid, $sns_oauth_token, $sns_oauth_token_secret, $me['name']);
     	//把新创建的用户放到ci->weixiao里
     	$this->weixiao->set_user_token($user->user_token);
     	$cur_user = $this->weixiao->get_cur_user();
     	if(empty($cur_user)) throw new Exception("something strange happens, cant get user just login.");
     	$data = array('user'=>$cur_user);
     	$this->load->view('binding/first_binding', $data);
     }
     else {
     	//老用户
     	//TODO 初次登录进入binding/first_binding,否则关闭弹出窗口,刷新父页面
     	$user = $this->usermanager->get_by_id($binding->user_id);
     	//把新创建的用户放到ci->weixiao里
     	$this->weixiao->set_user_token($user->user_token);
     	$cur_user = $this->weixiao->get_cur_user();
     	if(empty($cur_user)) throw new Exception("something strange happens, cant get user just login.");
     	$data = array('user'=>$cur_user);
     	$this->load->view('binding/not_first_binding', $data);
     }
     */
 }
コード例 #2
0
/**
 * 此函数,供Callback处调用,如果返回false,认证失败,否则返回以下哈希表:
 *   last_key  ->  callback得到的last_key
 *   oauth_token ->  上述lastkey中的oauth_token
 *   oauth_token_secret -> 上述lastkey中的oauth_token_secret
 *   user_id -> 用户ID
 *   user_name ->  用户昵称
 *   user_email -> 用户邮箱
 */
function AuthCallback_tencent()
{
    // 取得腾讯Auth对象
    $o = new MBOpenTOAuth(MB_AKEY, MB_SKEY, $_SESSION['keys']['oauth_token'], $_SESSION['keys']['oauth_token_secret']);
    // 获取last_key
    $last_key = $o->getAccessToken($_REQUEST['oauth_verifier']);
    if ($last_key) {
        $rtn = array();
        $rtn['last_key'] = $last_key;
        $rtn['oauth_token'] = $last_key['oauth_token'];
        $rtn['oauth_token_secret'] = $last_key['oauth_token_secret'];
        $rtn['user_id'] = $last_key['name'];
        $client = new MBApiClient(MB_AKEY, MB_SKEY, $last_key['oauth_token'], $last_key['oauth_token_secret']);
        $user = $client->getUserInfo();
        $rtn['user_name'] = $user['data']['nick'];
        $rtn['user_email'] = $user['data']['email'];
        return $rtn;
    } else {
        return $last_key;
    }
}
コード例 #3
0
ファイル: sync.php プロジェクト: yunsite/yuntongbu
<?php

@header('Content-Type:text/html;charset=utf-8');
include_once 'config.php';
include_once 'lib/oauth.php';
include_once 'lib/sina_api.php';
include_once 'lib/qq_api.php';
$sina_c = new WeiboClient(SINA_AKEY, SINA_SKEY, SINA_TOKEN, SINA_SECRET);
$qq_c = new MBApiClient(QQ_AKEY, QQ_SKEY, QQ_TOKEN, QQ_SECRET);
$mmc = memcache_init();
/* if(!isset(memcache_get($mmc,"sina_last_update"))){
		memcache_set($mmc,"sina_last_update","0");
	}
	
	if(!isset(memcache_get($mmc,"qq_last_update"))){
		memcache_set($mmc,"qq_last_update","0");
	} */
$sina_last_update = memcache_get($mmc, "sina_last_update");
$qq_last_update = memcache_get($mmc, "qq_last_update");
//同步腾讯微博到新浪微博
if (TOSINA == 0) {
    try {
        $qq_tweets = $qq_c->getMyTweet();
    } catch (Exception $e) {
        exit;
    }
    $isQqTrue = true;
    switch ($isQqTrue) {
        case $qq_tweets['data']['info'][0]['timestamp'] <= $qq_last_update:
            $isQqTrue = false;
            break;
コード例 #4
0
ファイル: Tencent_api.php プロジェクト: workplayteam/P2P
 public function send_message($data)
 {
     static $client = NULL;
     if ($client === NULL) {
         define("MB_RETURN_FORMAT", 'json');
         define("MB_API_HOST", 'open.t.qq.com');
         require_once APP_ROOT_PATH . 'system/api_login/Tencent/api_client.php';
         $uid = intval($GLOBALS['user_info']['id']);
         $udata = $GLOBALS['db']->getRow("select tencent_app_key,tencent_app_secret from " . DB_PREFIX . "user where id = " . $uid);
         $client = new MBApiClient($this->api['config']['app_key'], $this->api['config']['app_secret'], $udata['tencent_app_key'], $udata['tencent_app_secret']);
     }
     $p['c'] = $data['content'];
     //组装autho类所需的图片参数内容
     if (!empty($data['img'])) {
         $filename = $data['img'];
         $pic[0] = $this->get_image_mime($filename);
         $pic[1] = reset(explode('?', basename($filename)));
         $pic[2] = file_get_contents($filename);
         $p['p'] = $pic;
     }
     $p['ip'] = get_client_ip();
     $p['type'] = 1;
     try {
         $msg = $client->postOne($p);
         //			echo "success";
         //			print_r($msg);
     } catch (Exception $e) {
         //			echo "error";
         //			print_r($e);
     }
 }
コード例 #5
0
ファイル: cmd.php プロジェクト: dalinhuang/shopexts
<?php

@header('Content-Type:text/html;charset=utf-8');
session_start();
@(require_once 'config.php');
@(require_once 'oauth.php');
@(require_once 'opent.php');
@(require_once 'api_client.php');
$c = new MBApiClient(MB_AKEY, MB_SKEY, $_SESSION['last_key']['oauth_token'], $_SESSION['last_key']['oauth_token_secret']);
//时间线
$p = array('f' => 0, 't' => 0, 'n' => 5);
var_dump($c->getTimeline($p));
//拉取username的信息
$p = array('f' => 0, 't' => 0, 'n' => 5, 'name' => 'username');
//var_dump($c->getTimeline($p));
//拉取广播大厅消息
$p = array('p' => 0, 'n' => 5);
//var_dump($c->getPublic($p));
//拉取关于我的消息
$p = array('f' => 0, 'n' => 5, 't' => 0, 'l' => '', 'type' => 1);
//var_dump($c->getMyTweet($p));
//
//单条消息
$p = array('id' => 26016073563599);
//var_dump($c->getOne($p));
//
//发消息
//	*@content: 微博内容
$p = array('c' => '火车侠', 'ip' => $_SERVER['REMOTE_ADDR'], 'j' => '', 'w' => '');
//var_dump($c->postOne($p));
//
コード例 #6
0
ファイル: weibologin.class.php プロジェクト: tmlsoft/main
 function sendtalk()
 {
     $weibo = D('Weibobind');
     $ctent = D('Content');
     $user = Action::$login_user;
     $contentid = mysql_insert_id();
     if ($contentid) {
         $content = $ctent->where("content_id='{$contentid}'")->find();
         $text = $content['content_body'];
         $media = $content['media_body'];
         $text = str_replace('&amp;', '&', $text);
         $text = ubbreplace($text);
         $media = ubbreplace($content['media_body']);
         $st = getsubstr($media, 0, 7, false);
         if ($st == 'http://' || $st == '/photo/') {
             if ($st == '/photo/') {
                 $media = __PUBLIC__ . '/attachments' . $media;
                 $media = str_replace('s_', '', $media);
             }
             $text = $text . $media;
         }
         $text = clean_html($text);
     }
     if ($text) {
         $bind = $weibo->where("uid='{$user['user_id']}'")->find();
         if ($bind['sina_uid'] && $bind['sina_token'] && $bind['sina_tsecret'] && $bind['sendtosina'] == 1) {
             $sinawb = new WeiboClient(WB_AKEY, WB_SKEY, $bind['sina_token'], $bind['sina_tsecret']);
             $me = $sinawb->verify_credentials();
             if ($me['id'] == $bind['sina_uid']) {
                 $rssina = $sinawb->update($text);
             }
         }
         if ($bind['qq_uid'] && $bind['qq_token'] && $bind['qq_tsecret'] && $bind['sendtoqq'] == 1) {
             include_once "qqweibo/api_client.php";
             $qqwb = new MBApiClient(MB_AKEY, MB_SKEY, $bind['qq_token'], $bind['qq_tsecret']);
             $me = $qqwb->getUserInfo();
             if ($me['data']['name'] == $bind['qq_uid']) {
                 $p = array('c' => $text, 'ip' => $_SERVER['REMOTE_ADDR'], 'j' => '', 'w' => '');
                 $rsqq = $qqwb->postOne($p);
             }
         }
     }
 }
コード例 #7
0
ファイル: weibo.php プロジェクト: yunsite/joomla-sina-weibo
/**
 * 发送腾讯微博
 */
function sendTencentWeibo($weibocontent, $P)
{
    // 如果没有腾讯的授权,直接返回
    if (!$P['tencentlastkey']) {
        return;
    }
    // 准备微博对象
    $c = new MBApiClient(MB_AKEY, MB_SKEY, $P['tencentlastkey']['oauth_token'], $P['tencentlastkey']['oauth_token_secret']);
    // 如果有图片,上传图片,发表有图片的微博
    if ($weibocontent['imgfile']) {
        $p = array('c' => $weibocontent['text'], 'ip' => $_SERVER['REMOTE_ADDR'], 'j' => '', 'w' => '', 'p' => array(null, 'pic from joomla', $weibocontent['imgfile']), 'type' => 0);
    } else {
        // 发表没有图片的微博
        $p = array('c' => $weibocontent['text'], 'ip' => $_SERVER['REMOTE_ADDR'], 'j' => '', 'w' => '');
    }
    $rtn = $c->postOne($p);
}
コード例 #8
0
ファイル: action.php プロジェクト: yunsite/micro-fan
 }
 //if has video then add
 $user = sql_query('SELECT * FROM ' . DB_PREFIX . 'user WHERE username = "******"');
 $user = mysql_fetch_array($user);
 $microblog = unserialize($user['microblog']);
 if (is_array($mblog)) {
     foreach ($mblog as $key => $var) {
         if ($var == 'fanfou') {
             sync_fanfou(strip_tags($entry), $microblog['ff']['name'], $microblog['ff']['pass']);
         } elseif ($var == 'sina') {
             $c = new WeiboClient(WB_AKEY, WB_SKEY, $microblog['sina']['oauth_token'], $microblog['sina']['oauth_token_secret']);
             $c->update($entry);
         } elseif ($var == 'digu') {
             sync_digu(strip_tags($entry), $microblog['dg']['name'], $microblog['dg']['pass']);
         } elseif ($var == 'qq') {
             $tecent = new MBApiClient(MB_AKEY, MB_SKEY, $microblog['qq']['oauth_token'], $microblog['qq']['oauth_token_secret']);
             $p = array('c' => $entry, 'ip' => $_SERVER['REMOTE_ADDR'], 'j' => '', 'w' => '');
             $tecent->postOne($p);
         } elseif ($var == '163') {
             $wangyi = new wy_WeiboClient(WY_AKEY, WY_SKEY, $microblog['163']['oauth_token'], $microblog['163']['oauth_token_secret']);
             $wangyi->update($entry);
         } elseif ($var == 'sohu') {
             sync_sohu($entry, $microblog['sh']['name'], $microblog['sh']['pass']);
         } elseif ($var == 'tumblr') {
             sync_tumblr($entry, $microblog['tumblr']['name'], $microblog['tumblr']['pass']);
         } elseif ($var == 'leihou') {
             sync_leihou($entry, $microblog['lh']['name'], $microblog['lh']['pass']);
         }
     }
 }
 if ($_GET['type'] == 'm') {
コード例 #9
0
ファイル: weibo.php プロジェクト: apachesep/joomla-weibo
/**
 * 发送腾讯微博
 */
function sendTencentWeibo($row, $P)
{
    // 如果没有得到本类微博的授权,不发表
    if (!$P['tencentlastkey']) {
        return false;
    }
    $option = $P['typeoption']['tencent'];
    if (!$option) {
        return false;
    }
    // 准备微博文字和图片
    getWeiboText($row, $option, $weibocontent);
    // 准备微博对象
    try {
        $c = new MBApiClient(MB_AKEY, MB_SKEY, $P['tencentlastkey']['oauth_token'], $P['tencentlastkey']['oauth_token_secret']);
        // 如果有图片,上传图片,发表有图片的微博
        if ($weibocontent['imgfile']) {
            $p = array('c' => $weibocontent['text'], 'ip' => $_SERVER['REMOTE_ADDR'], 'j' => '', 'w' => '', 'p' => array(null, 'pic from joomla', $weibocontent['imgfile']), 'type' => 0);
        } else {
            // 发表没有图片的微博
            $p = array('c' => $weibocontent['text'], 'ip' => $_SERVER['REMOTE_ADDR'], 'j' => '', 'w' => '');
        }
        $rtninfo = $c->postOne($p);
    } catch (Exception $e) {
        return false;
    }
    if ($rtninfo['error_code']) {
        return false;
    }
    return "type=tencent:id={$rtninfo['data']['id']}";
}
コード例 #10
0
ファイル: function.php プロジェクト: omusico/jianli
function yjl_uwb($u, $c, $i, $e = '', $p = '')
{
    global $r_main, $yjl_tpath, $dbprefix, $yjl_url, $yjl_isdebug;
    if ($yjl_isdebug == 0) {
        if (trim($r_main['sina_k']) != '' && trim($r_main['sina_s']) != '') {
            $q_rex = sprintf('select profile, access_token from %s where uid=%s and length(access_token)>0 limit 1', $dbprefix . 'xwb_bind_info', $u);
            $rex = mysql_query($q_rex) or die(mysql_error());
            $r_rex = mysql_fetch_assoc($rex);
            if (mysql_num_rows($rex) > 0) {
                $a_xwb = json_decode($r_rex['profile'], true);
                if (isset($a_xwb['bind_setting']) && $a_xwb['bind_setting'] == 1) {
                    require_once $e . 'lib/saetv2.ex.class.php';
                    $so = new SaeTClientV2($r_main['sina_k'], $r_main['sina_s'], $r_rex['access_token']);
                    if ($p != '') {
                        $rs = $so->upload($c, $e . $p);
                    } else {
                        $rs = $so->update($c);
                    }
                    if (isset($rs['mid']) && $rs['mid'] != '') {
                        $iSQL = sprintf('insert into %s (tid, mid) values (%s, %s)', $dbprefix . 'xwb_bind_topic', $i, $rs['mid']);
                        $result = mysql_query($iSQL) or die(mysql_error());
                    }
                }
            }
            mysql_free_result($rex);
        }
        if (trim($r_main['tqq_k']) != '' && trim($r_main['tqq_s']) != '') {
            $q_rex = sprintf('select token, tsecret from %s where uid=%s and length(token)>0 and length(tsecret)>0 and synctoqq>0 limit 1', $dbprefix . 'qqwb_bind_info', $u);
            $rex = mysql_query($q_rex) or die(mysql_error());
            $r_rex = mysql_fetch_assoc($rex);
            if (mysql_num_rows($rex) > 0) {
                require_once $e . 'lib/tqq_opent.php';
                require_once $e . 'lib/tqq_client.php';
                $tqq = new MBApiClient($r_main['tqq_k'], $r_main['tqq_s'], $r_rex['token'], $r_rex['tsecret']);
                $tqq_a = array('c' => $c, 'ip' => $_SERVER['REMOTE_ADDR'], 'j' => '', 'w' => '', 'type' => 1);
                if ($p != '') {
                    $ps = getimagesize($p);
                    $p_data = file_get_contents($p);
                    $tqq_a['p'] = array($ps['mime'], $p, $p_data);
                }
                $rq = $tqq->postOne($tqq_a);
                if (isset($rq['data']['id']) && $rq['data']['id'] != '') {
                    $iSQL = sprintf('insert into %s (tid, qqwb_id) values (%s, %s)', $dbprefix . 'qqwb_bind_topic', $i, $rq['data']['id']);
                    $result = mysql_query($iSQL) or die(mysql_error());
                }
            }
            mysql_free_result($rex);
        }
    }
}
コード例 #11
0
ファイル: cmdpic.php プロジェクト: dalinhuang/shopexts
<?php

@header('Content-Type:text/html;charset=utf-8');
session_start();
@(require_once 'config.php');
@(require_once 'oauth.php');
@(require_once 'opent.php');
@(require_once 'api_client.php');
if (isset($_POST['content'])) {
    $c = new MBApiClient(MB_AKEY, MB_SKEY, $_SESSION['last_key']['oauth_token'], $_SESSION['last_key']['oauth_token_secret']);
    //发消息
    //	*@content: 微博内容
    $p = array('c' => $_POST['content'], 'ip' => $_SERVER['REMOTE_ADDR'], 'j' => '', 'w' => '', 'p' => array($_FILES['pic']['type'], $_FILES['pic']['name'], file_get_contents($_FILES['pic']['tmp_name'])), 'type' => 0);
    print_r($c->postOne($p));
}
?>


<!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>无标题文档</title>
</head>

<body>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
  内容:<input type="text" name="content" id="content" />
  图片:<input type="file" name="pic" id="pic" />
  <input type="submit" name="button" id="button" value="提交" />
</form>