Created
February 17, 2011 09:15
-
-
Save marshluca/831365 to your computer and use it in GitHub Desktop.
腾讯微薄OAuth授权
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- OAuth回调地址,绑定我易网用户 --> | |
<?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'); | |
// 获取Acess Token | |
$o = new MBOpenTOAuth( MB_AKEY , MB_SKEY , $_SESSION['keys']['oauth_token'] , $_SESSION['keys']['oauth_token_secret'] ); | |
$last_key = $o->getAccessToken( $_REQUEST['oauth_verifier'] ); | |
$_SESSION['last_key'] = $last_key; | |
// 获取用户的信息 | |
$c = new MBApiClient( MB_AKEY , MB_SKEY , $_SESSION['last_key']['oauth_token'] , $_SESSION['last_key']['oauth_token_secret'] ); | |
$response = $c->getUserInfo(); | |
// 重定向到我易网登录API,绑定我易网用户id | |
$url = "http://api.5yi.com:9080/third_login/t_qq?token=".$last_key['oauth_token']."&secret=".$last_key['oauth_token_secret']."&uid=".$response['data']['name']."&uname=".$response['data']['nick']."&source=tqq"; | |
header("Location: ".$url); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 调用PHP接口,发送微博信息 --> | |
<?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'] ); | |
$c = new MBApiClient( MB_AKEY , MB_SKEY , $_REQUEST['oauth_token'] , $_REQUEST['oauth_token_secret'] ); | |
//发消息 | |
$p =array( | |
'c' => ''.$_REQUEST["text"], | |
'ip' => $_SERVER['REMOTE_ADDR'], | |
'j' => '', | |
'w' => '' | |
); | |
var_dump($c->postOne($p)); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment