PHP third-party login Weibo login video tutorial

黄舟
Release: 2023-03-15 16:10:02
Original
1483 people have browsed it

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.

PHP third-party login Weibo login video tutorial

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" , '************' );//申请的时候 填写的回调地址
Copy after login
<button onclick="xinlang()" class="u-btn btn-wb">使用微博帐号登录</button>
Copy after login
function xinlang(){  
          window.location.href = "<{$web_url}>/index.php/login/xinlang";  
      }
Copy after login
/* 
     * 这个是用新浪登录 
     */  
    public function xinlang(){  
        include_once( &#39;/xinlang/config.php&#39; );  
        include_once( &#39;/xinlang/saetv2.ex.class.php&#39; );  
        $o = new SaeTOAuthV2( WB_AKEY , WB_SKEY );  
        $code_url = $o->getAuthorizeURL( WB_CALLBACK_URL );  
        header("location:".$code_url);  
    }
Copy after login
include_once( &#39;/xinlang/config.php&#39; );  
          include_once( &#39;/xinlang/saetv2.ex.class.php&#39; );  
          $o = new SaeTOAuthV2( WB_AKEY , WB_SKEY );  
          $keys = array();  
          $keys[&#39;code&#39;] = $_REQUEST[&#39;code&#39;];  
          $keys[&#39;redirect_uri&#39;] = WB_CALLBACK_URL;  
              $token = $o->getAccessToken( &#39;code&#39;, $keys ) ;  
                  $c = new SaeTClientV2( WB_AKEY , WB_SKEY ,$token["access_token"]);  
                  $ms = $c->home_timeline(); // done  
                  $uid_get = $c->get_uid();  
                  $uid =  $token[&#39;uid&#39;];  
                  $user_message = $c->show_user_by_id( $token[&#39;uid&#39;]);//根据ID获取用户等基本信息
Copy after login

Then we can use

var_dump($user_message);//显示新浪接口给我们展示的用户信息的有关资料了
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template