Introduction: If you want to use the simplest method to acquire new users for our web application, you should never miss "PHP Third-Party Login - Weibo Login Video Tutorial". This course will teach you how to use the SDK provided by the Weibo Open Platform to quickly access the Weibo Open Platform and quickly acquire a large number of users.
Course playback address: http://www.php.cn/course/400.html
The teacher’s teaching style:
The teacher’s lectures are vivid, witty, witty, and touching. A vivid metaphor is like the finishing touch, opening the door to wisdom for students; a well-placed humor brings a knowing smile to students, like drinking a glass of mellow wine, giving people aftertaste and nostalgia; a philosopher's aphorisms, cultural references Proverbs are interspersed from time to time in the narration, giving people thinking and warning.
The more difficult point in this video is the development of php Weibo login:
Sina Weibo login
The prerequisite is that two files need to be implemented saetv2.ex.class.PHP and config.php in the same directory
saetv2.ex.class.php code can be downloaded from Baidu
config.php needs to be configured by yourself
define( "WB_AKEY" , '********' );//这个在新浪申请 填上即可 define( "WB_SKEY" ,'*************' );//这个在新浪申请 填上即可 define( "WB_CALLBACK_URL" , '************' );//申请的时候 填写的回调地址
<button onclick="xinlang()" class="u-btn btn-wb">使用微博帐号登录</button>
function xinlang(){ window.location.href = "<{$web_url}>/index.php/login/xinlang"; }
/* * 这个是用新浪登录 */ public function xinlang(){ include_once( '/xinlang/config.php' ); include_once( '/xinlang/saetv2.ex.class.php' ); $o = new SaeTOAuthV2( WB_AKEY , WB_SKEY ); $code_url = $o->getAuthorizeURL( WB_CALLBACK_URL ); header("location:".$code_url); }
include_once( '/xinlang/config.php' ); include_once( '/xinlang/saetv2.ex.class.php' ); $o = new SaeTOAuthV2( WB_AKEY , WB_SKEY ); $keys = array(); $keys['code'] = $_REQUEST['code']; $keys['redirect_uri'] = WB_CALLBACK_URL; $token = $o->getAccessToken( 'code', $keys ) ; $c = new SaeTClientV2( WB_AKEY , WB_SKEY ,$token["access_token"]); $ms = $c->home_timeline(); // done $uid_get = $c->get_uid(); $uid = $token['uid']; $user_message = $c->show_user_by_id( $token['uid']);//根据ID获取用户等基本信息
Then we can use
var_dump($user_message);//显示新浪接口给我们展示的用户信息的有关资料了
The above is the detailed content of PHP third-party login Weibo login video tutorial. For more information, please follow other related articles on the PHP Chinese website!