1 session_start(); 2 3 include_once( 'config.php' ); 4 include_once( 'saetv2.ex.class.php' ); 5 6 $o = new SaeTOAuthV2( WB_AKEY , WB_SKEY ); 7 8 if (isset($_REQUEST['code'])) { 9 $keys = array(); 10 $keys['code'] = $_REQUEST['code']; 11 $keys['redirect_uri'] = WB_CALLBACK_URL; 12 try { 13 $token = $o->getAccessToken( 'code', $keys ) ; 14 } catch (OAuthException $e) { 15 } 16 } 17 18 if ($token) { 19 $_SESSION['token'] = $token; 20 setcookie( 'weibojs_'.$o->client_id, http_build_query($token) ); 21 ?> 22 授权完成,<a href="weibolist.php">进入你的微博列表页面</a><br /> 23 <?php 24 } else { 25 ?> 26 授权失败。 27 <?php 28 } 29 ?>