[项目]新浪微博应用

3、发送信息(微博)
$content = htmlspecialchars($content);
$c = new WeiboClient( APIKEY, SECRETKEY, $last_key['oauth_token'], $last_key['oauth_token_secret']);
$r = $c->update($content);
if(empty($r['error_code'])){
        echo json_encode(returnArray(100));
        exit;
}


2、获取access_token
//当进入游戏时,对方会把verifier传过来的

$oauth_verifier = get('oauth_verifier');
if(empty($_COOKIE['access_oauth_token']) || empty($_COOKIE['access_oauth_token_secret'])) {
    if(empty($oauth_verifier)){
        $o = new WeiboOAuth( $platinfo['apikey'], $platinfo['secretkey']);
        $keys = $o->getRequestToken();
        $_SESSION['keys'] = $keys;
        $aurl = $o->getAuthorizeURL( $keys['oauth_token'], false,  $siteurl.'/weibo/index.php');
        if(empty($aurl)){
            echo '<script>window.top.location.reload();</script>';
            exit;
        }
        //echo $aurl;exit;
        echo '<script>', 'location.href="', $aurl, '";', '</script>';
        exit;
    }
    if(!empty($oauth_verifier)){
        $o = new WeiboOAuth($platinfo['apikey'], $platinfo['secretkey'], $_SESSION['keys']['oauth_token'], $_SESSION['keys']['oauth_token_secret']);
        $last_key = $o->getAccessToken($oauth_verifier);

        if(empty($last_key)) exit('last_key 错误');
       
        $c = new WeiboClient( $platinfo['apikey'] , $platinfo['secretkey']  , $last_key['oauth_token'] , $last_key['oauth_token_secret']);
        $me = $c->verify_credentials();

        //print_r($me);exit;
        //
        setcookie('request_oauth_verifier', $oauth_verifier);
        setcookie('access_oauth_token', $last_key['oauth_token']);
        setcookie('access_oauth_token_secret', $last_key['oauth_token_secret']);
        setcookie('user_id', $me['id']);
        setcookie('screen_name', empty($me['screen_name']) ? $me['name'] : $me['screen_name']);
       
        $last_key['screen_name'] = empty($me['screen_name']) ? $me['name'] : $me['screen_name'];
        $last_key['user_id']     = $me['id'];
    }
}else{
    $last_key['oauth_token']         = $_COOKIE['access_oauth_token'];
    $last_key['oauth_token_secret'] = $_COOKIE['access_oauth_token_secret'];
    $last_key['user_id']            = $_COOKIE['user_id'];
    $last_key['screen_name']        = $_COOKIE['screen_name'];
}


1、iframe式关注按钮
http://widget.weibo.com/relationship/followbutton.php?width=200&height=22&uid=2297141140&style=3&btn=red&dpc=1
300*300
  • 没有相关文章
  • 没有评论
 文章首页关于迷茫时代关于我写意人生
版权所有:迷茫时代 All rights reserved   
执行时间:0.00416 秒