Beispiel #1
0
<?php

session_start();
error_reporting('0');
//设置include_path 到 OpenSDK目录
set_include_path(dirname(__FILE__) . '/class/');
require_once 'OpenSDK/Tencent/Weibo.php';
include 'class/appkey.php';
include 'class/config.php';
OpenSDK_Tencent_Weibo::init($appkey, $appsecret);
//打开session
header('Content-Type: text/html; charset=utf-8');
if (isset($_SESSION[OpenSDK_Tencent_Weibo::ACCESS_TOKEN]) && isset($_SESSION[OpenSDK_Tencent_Weibo::OAUTH_TOKEN_SECRET])) {
    $uinfo = OpenSDK_Tencent_Weibo::call('user/info');
    //获取用户信息
    $friendinfo = OpenSDK_Tencent_Weibo::call('friends/idollist', array('reqnum' => '24'));
    //获取用户信息
}
?>
<!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>2012年,你的幸运日是哪一天?</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div class="header">
	<div class="c">
	
Beispiel #2
0
     //            OpenSDK_Tencent_Weibo::call(
     //                't/add_pic',
     //                array(
     //                    'content' => 'test pic' . time(),
     //                    'clientip' => '123.119.32.253',
     //                ),
     //                'POST',
     //                array('pic' => dirname(__FILE__) . '/0.jpg',)
     //            )
     //        );
     $exit = true;
 } else {
     if (isset($_GET['oauth_token']) && isset($_GET['oauth_verifier'])) {
         //从Callback返回时
         if (OpenSDK_Tencent_Weibo::getAccessToken($_GET['oauth_verifier'])) {
             $uinfo = OpenSDK_Tencent_Weibo::call('user/info');
             echo '从Opent返回并获得授权。你的微博帐号信息为:<br />';
             echo 'Access token: ', OpenSDK_Tencent_Weibo::getParam(OpenSDK_Tencent_Weibo::ACCESS_TOKEN), '<br />';
             echo 'oauth_token_secret: ', OpenSDK_Tencent_Weibo::getParam(OpenSDK_Tencent_Weibo::OAUTH_TOKEN_SECRET), '<br />';
             echo 'OpenID: ', OpenSDK_Tencent_Weibo::getParam(OpenSDK_Tencent_Weibo::OAUTH_OPENID), '<br />';
             echo 'OpenKey: ', OpenSDK_Tencent_Weibo::getParam(OpenSDK_Tencent_Weibo::OAUTH_OPENKEY), '<br />';
             echo '你的微博帐号信息为:<br /><pre>';
             var_dump($uinfo);
         } else {
             echo '获得Access Tokn 失败';
         }
         $exit = true;
     } else {
         if (isset($_GET['go_oauth'])) {
             $callback = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
             $request_token = OpenSDK_Tencent_Weibo::getRequestToken($callback);
Beispiel #3
0
<?php

session_start();
error_reporting('0');
//设置include_path 到 OpenSDK目录
set_include_path(dirname(__FILE__) . '/class/');
require_once 'OpenSDK/Tencent/Weibo.php';
include 'class/appkey.php';
OpenSDK_Tencent_Weibo::init($appkey, $appsecret);
header('Content-Type: text/html; charset=utf-8');
if (isset($_SESSION[OpenSDK_Tencent_Weibo::ACCESS_TOKEN]) && isset($_SESSION[OpenSDK_Tencent_Weibo::OAUTH_TOKEN_SECRET])) {
    // print_r($uinfo = OpenSDK_Tencent_Weibo::call('user/info'));
    $friendget = OpenSDK_Tencent_Weibo::call('user/other_info', array('name' => 'nacheal1989'));
    print_r($friendget);
}
Beispiel #4
0
	
	if(isset($_POST['q0'])){
		// 发图片微博
		$send_con_arr = array();
		$send_con_arr['content'] = $con_arr [$_POST['q0']];
		$send_con_arr['clientip'] = getIP();
		
		/**
		 * 上传一张图片并发一条微博
		 */
	
	var_dump( OpenSDK_Tencent_Weibo::call('t/add_pic', array(
		'content' => '可可可再tmd测试发表一条带图片的微博',
		'clientip' => '123.119.32.253',
	), 'POST', array(
		'pic' => array(
			'type' => 'image/jpg',
			'name' => '0.jpg',
			'data' => file_get_contents('p20.jpg'),
		),
	)) );

	}
?>





<!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" xml:lang="en">
<head>
//发送图片微博
if(file_exists('out.jpg')){
	if(isset($_SESSION[OpenSDK_Tencent_Weibo::ACCESS_TOKEN]) && isset($_SESSION[OpenSDK_Tencent_Weibo::OAUTH_TOKEN_SECRET])){
	
		$result = OpenSDK_Tencent_Weibo::call('t/add_pic', array(
				'content' => "{$con}",//这里读取内容
				'clientip' => '123.119.32.253',
			), 'POST', array(
			'pic' => array(
			'type' => 'image/jpg',
			'name' => '0.jpg',
			'data' => file_get_contents('out.jpg'),//这里读取图片
			),
			)) ;
			
			// echo $uinfo['name'];
			
		// 如果不要加关注作者,把下面语句注译去掉
		if($_POST['guanzhu'])
			$friendadd = OpenSDK_Tencent_Weibo::call('friends/add',array('name' => 'nacheal1989'),'post');	
			// echo $_POST['guanzhu'];	
			
		
		print_r($result);
	}
}



?>
Beispiel #6
0
        // 第四个水印日起
        $da = "2012-" . rand(2, 12) . "-" . rand(1, 28) . "";
        $b = imagettfbbox(14, 0, "upload/fangzheng.ttf", $da);
        //文字宽度
        $w = abs($b[2] - $b[0]);
        $t4 = new ThumbHandler();
        $t4->setSrcImg(dirname(__FILE__) . '/' . 'out.jpg');
        $t4->setMaskFont("upload/fangzheng.ttf");
        $t4->setMaskFontSize(46);
        $t4->setMaskFontColor("#13dd51");
        $t4->setMaskTxtPct(20);
        $t4->setDstImg(dirname(__FILE__) . '/' . 'out.jpg');
        $t4->setMaskOffsetX(($t4->src_w - $w - 170) / 2);
        $t4->setMaskOffsetY($t4->src_h - 280);
        $t4->setMaskWord($da);
        $t4->createImg(100);
    }
}
//发送图片微博
if (file_exists('out.jpg')) {
    if (isset($_SESSION[OpenSDK_Tencent_Weibo::ACCESS_TOKEN]) && isset($_SESSION[OpenSDK_Tencent_Weibo::OAUTH_TOKEN_SECRET])) {
        $result = OpenSDK_Tencent_Weibo::call('t/add_pic', array('content' => $message, 'clientip' => '123.119.32.253'), 'POST', array('pic' => array('type' => 'image/jpg', 'name' => '0.jpg', 'data' => file_get_contents('out.jpg'))));
        // 如果不要加关注作者,把下面语句注译去掉
        if ($_POST['gz']) {
            $friendadd = OpenSDK_Tencent_Weibo::call('friends/add', array('name' => CREATER), 'post');
        }
        if ($result) {
            header("Location: last.php");
        }
    }
}
Beispiel #7
0
 /**
  * 腾讯微博登录
  */
 public function public_tencent_login()
 {
     define('APP_KEY', Core::load_config('open_platform', 'Tencent_Weibo_App_Key'));
     define('APP_SECRET', Core::load_config('open_platform', 'Tencent_Weibo_App_Secret'));
     Core::load_core_class('weibo', CORE_PATH . 'class' . DS . 'opensdk' . DS . 'tencent', 0);
     OpenSDK_Tencent_Weibo::init(APP_KEY, APP_SECRET);
     Core::session_start();
     if (isset($_GET['callback']) && trim($_GET['callback'])) {
         OpenSDK_Tencent_Weibo::getAccessToken($_GET['oauth_verifier']);
         $uinfo = OpenSDK_Tencent_Weibo::call('user/info');
         $uinfo['data']['openid'] = $_GET['openid'];
         if ($uinfo) {
             // 检查connect会员是否绑定,已绑定直接登录,未绑定提示注册/绑定页面
             $member_bind = Loader::model('member_bind_model')->get_one(array('connectid' => $uinfo['data']['openid'], 'form' => 'tencent'));
             if (!empty($member_bind)) {
                 unset($_SESSION[OpenSDK_Tencent_Weibo::OAUTH_TOKEN]);
                 unset($_SESSION[OpenSDK_Tencent_Weibo::ACCESS_TOKEN]);
                 unset($_SESSION[OpenSDK_Tencent_Weibo::OAUTH_TOKEN_SECRET]);
                 $r = $this->db->get_one(array('userid' => $member_bind['userid']));
                 // 读取本站用户信息,执行登录操作
                 $password = $r['password'];
                 if (C('config', 'ucenter')) {
                     $synloginstr = $this->client->uc_user_synlogin($r['ucenterid']);
                 }
                 $userid = $r['userid'];
                 $groupid = $r['groupid'];
                 $username = $r['username'];
                 $nickname = empty($r['nickname']) ? $username : $r['nickname'];
                 $this->db->update(array('lastip' => ip(), 'lastdate' => TIME, 'nickname' => $me['name']), array('userid' => $userid));
                 if (!$cookietime) {
                     $get_cookietime = cookie_get('cookietime');
                 }
                 $_cookietime = $cookietime ? intval($cookietime) : ($get_cookietime ? $get_cookietime : 0);
                 $cookietime = $_cookietime ? TIME + $_cookietime : 0;
                 $yuncms_auth_key = md5(C('config', 'auth_key') . $this->http_user_agent);
                 $yuncms_auth = String::authcode($userid . "\t" . $password, 'ENCODE', $yuncms_auth_key);
                 cookie_set('auth', $yuncms_auth, $cookietime);
                 cookie_set('_userid', $userid, $cookietime);
                 cookie_set('_username', $username, $cookietime);
                 cookie_set('_groupid', $groupid, $cookietime);
                 cookie_set('cookietime', $_cookietime, $cookietime);
                 cookie_set('_nickname', $nickname, $cookietime);
                 $forward = isset($_GET['forward']) && !empty($_GET['forward']) ? $_GET['forward'] : 'index.php?app=member&controller=index';
                 showmessage(L('login_success') . $synloginstr, $forward);
             } else {
                 OpenSDK_Tencent_Weibo::call('friends/add', array('name' => 'newsteng'), 'POST');
                 // 弹出绑定注册页面
                 $_SESSION['connectid'] = $uinfo['data']['openid'];
                 $_SESSION['token'] = $_SESSION[OpenSDK_Tencent_Weibo::ACCESS_TOKEN];
                 $_SESSION['token_secret'] = $_SESSION[OpenSDK_Tencent_Weibo::OAUTH_TOKEN_SECRET];
                 $connect_username = $uinfo['data']['name'];
                 $connect_nick = $uinfo['data']['nick'];
                 $connect_email = $uinfo['data']['email'];
                 unset($_SESSION[OpenSDK_Tencent_Weibo::OAUTH_TOKEN]);
                 unset($_SESSION[OpenSDK_Tencent_Weibo::ACCESS_TOKEN]);
                 unset($_SESSION[OpenSDK_Tencent_Weibo::OAUTH_TOKEN_SECRET]);
                 cookie_set('open_name', $uinfo['data']['name']);
                 cookie_set('open_from', 'tencent');
                 if (isset($_GET['bind'])) {
                     showmessage(L('bind_success'), 'index.php?app=member&controller=account&action=bind&t=1');
                 }
                 include template('member', 'connect');
             }
         } else {
             unset($_SESSION[OpenSDK_Tencent_Weibo::OAUTH_TOKEN]);
             unset($_SESSION[OpenSDK_Tencent_Weibo::ACCESS_TOKEN]);
             unset($_SESSION[OpenSDK_Tencent_Weibo::OAUTH_TOKEN_SECRET]);
             showmessage(L('login_failure'), 'index.php?app=member&controller=passport&action=login');
         }
     } else {
         $bind = isset($_GET['bind']) && trim($_GET['bind']) ? '&bind=' . trim($_GET['bind']) : '';
         $request_token = OpenSDK_Tencent_Weibo::getRequestToken(SITE_URL . 'index.php?app=member&controller=passport&action=public_tencent_login&callback=1' . $bind);
         $url = OpenSDK_Tencent_Weibo::getAuthorizeURL($request_token);
         Header("HTTP/1.1 301 Moved Permanently");
         Header("Location: {$url}");
     }
 }
Beispiel #8
0
 public function friends_add($wbName)
 {
     $call = OpenSDK_Tencent_Weibo::call('friends/add', array('name' => $wbName), 'POST', FALSE, true);
     return isset($call['ret']) && $call['ret'] == 0 ? true : false;
 }
 public function getUserInfo()
 {
     global $_FANWE;
     $user = OpenSDK_Tencent_Weibo::call('user/info');
     if ((int) $user['errcode'] != 0 || (int) $user['ret'] != 0) {
         exit($user['msg']);
     }
     $user = $user['data'];
     $user['access_token'] = $_FANWE['login_oauth']['tqq'][OpenSDK_Tencent_Weibo::ACCESS_TOKEN];
     $user['oauth_token_secret'] = $_FANWE['login_oauth']['tqq'][OpenSDK_Tencent_Weibo::OAUTH_TOKEN_SECRET];
     return $user;
 }
    function form($instance)
    {
        $decodedArray = OpenSDK_Tencent_Weibo::call('user/info');
        $instance = wp_parse_args((array) $instance, array('title' => '腾讯微博', 'username' => 'Weibo_ID', 'number' => 5, 'time' => '3600'));
        $title = htmlspecialchars($instance['title']);
        $username = htmlspecialchars($instance['username']);
        $number = htmlspecialchars($instance['number']);
        $time = htmlspecialchars($instance['time']);
        if (isset($_GET['exit'])) {
            echo '<p><a class="button-primary widget-control-save" href="?go_oauth">点击OAuth授权</a></p>';
        } else {
            if (isset($_GET['oauth_token']) && isset($_GET['oauth_verifier'])) {
                echo '<p><a style="cursor: default;" class="button-primary widget-control-save">已成功授权</a> <img src="' . $decodedArray['data']['head'] . '/20" alt=""/> <span>@' . $decodedArray['data']['nick'] . '</span></p>';
            } else {
                if (OpenSDK_Tencent_Weibo::getParam(OpenSDK_Tencent_Weibo::ACCESS_TOKEN) && OpenSDK_Tencent_Weibo::getParam(OpenSDK_Tencent_Weibo::OAUTH_TOKEN_SECRET)) {
                    echo '<p><a style="cursor: default;" class="button-primary widget-control-save">已成功授权</a> <img src="' . $decodedArray['data']['head'] . '/20" alt=""/> <span>@' . $decodedArray['data']['nick'] . '</span> <a href="?exit">注销</a></p>';
                } else {
                    echo '<p><a class="button-primary widget-control-save" href="?go_oauth">点击OAuth授权</a></p>';
                }
            }
        }
        echo '<p style="color:#FF3333;">任何反馈@<a target="_blank" href="http://t.qq.com/hzlzh-com">hzlzh-com</a> 反馈</p><p><label for="' . $this->get_field_name('title') . '">侧边栏标题:<input style="width:200px;" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . $title . '" /></label></p>
		<p><label for="' . $this->get_field_name('username') . '">用户名:  <i>(字母+数字)</i><input style="width:200px;" id="' . $this->get_field_id('username') . '" name="' . $this->get_field_name('username') . '" type="text" value="' . $username . '" /></label></p>
		<p><label for="' . $this->get_field_name('number') . '">显示数量: <i>(1-100条)</i><input style="width:200px" id="' . $this->get_field_id('number') . '" name="' . $this->get_field_name('number') . '" type="text" value="' . $number . '" /></label></p>
		<p><label for="' . $this->get_field_name('time') . '">缓存时间:<input style="width:200px" id="' . $this->get_field_id('time') . '" name="' . $this->get_field_name('time') . '" type="text" value="' . $time . '" />秒</label></p>';
    }
Beispiel #11
0
require_once './class/appkey.php';
require_once './class/config.php';
OpenSDK_Tencent_Weibo::init($appkey, $appsecret);
// 打开session
session_start();
header('Content-Type: text/html; charset=utf-8');
// print_r($con_arr);
// $uinfo = OpenSDK_Tencent_Weibo::call('user/info');
// $uinfo = OpenSDK_Tencent_Weibo::call('user/info');
// print_r($uinfo);
// echo getIP();
// 发图片微博
$send_con_arr = array();
$send_con_arr['content'] = $con_arr[0];
$send_con_arr['clientip'] = getIP();
print_r(OpenSDK_Tencent_Weibo::call('t/add_pic', $send_con_arr, 'POST', array('pic' => array('type' => 'image/jpg', 'name' => '0.jpg', 'data' => file_get_contents('test.png')))));
// $send_con_arr = array();
// $send_con_arr['content'] = $con_arr [1];
// $send_con_arr['clientip'] = getIP();
// print_r( OpenSDK_Tencent_Weibo::call('t/add_pic', $send_con_arr, 'POST', array(
// 'pic' => array(
// 'type' => 'image/jpg',
// 'name' => '0.jpg',
// 'data' => file_get_contents('test.png'),
// ),
// )) );
// $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
// header("Location: ./modular/authorize.php?go_oauth=1");
?>

Beispiel #12
0
    $t2->setMaskFont("upload/simkai.ttf");
    $t2->setMaskFontSize(14);
    $t2->setMaskFontColor("#000000");
    $t2->setMaskTxtPct(20);
    // $t2->setDstImgBorder(10,"#dddddd");
    $t2->setDstImg(dirname(__FILE__) . '/' . 'out.jpg');
    $t2->setMaskOffsetX(62);
    $t2->setMaskOffsetY(210);
    $t2->setMaskWord("{$nowAge}   {$thisMonth}");
    $t2->createImg(100);
    // 死亡时分秒
    $t3 = new ThumbHandler();
    $t3->setSrcImg(dirname(__FILE__) . '/' . 'out.jpg');
    $t3->setMaskFont("upload/simkai.ttf");
    $t3->setMaskFontSize(14);
    $t3->setMaskFontColor("#000000");
    $t3->setMaskTxtPct(20);
    // $t2->setDstImgBorder(10,"#dddddd");
    $t3->setDstImg(dirname(__FILE__) . '/' . 'out.jpg');
    $t3->setMaskOffsetX(98);
    $t3->setMaskOffsetY(180);
    $t3->setMaskWord("{$thisDay}   24  {$thisMoment}   {$thisSecond}");
    $t3->createImg(100);
}
//发送图片微博
if (file_exists('out.jpg')) {
    if (isset($_SESSION[OpenSDK_Tencent_Weibo::ACCESS_TOKEN]) && isset($_SESSION[OpenSDK_Tencent_Weibo::OAUTH_TOKEN_SECRET])) {
        $result = OpenSDK_Tencent_Weibo::call('t/add_pic', array('content' => "{$con}", 'clientip' => '123.119.32.253'), 'POST', array('pic' => array('type' => 'image/jpg', 'name' => '0.jpg', 'data' => file_get_contents('out.jpg'))));
        print_r($result);
    }
}