1:第三方配置主要也是这里的验证地址
2:引入官方SDK 三部曲
第一步 页面跳转,第二步 拼接请求的地址 ,第三步 更具获取的token去获取用的信息
#微博
public function getWechat(){
session_start();
require_once("../app/Helper/extend/libweibo/config.php");
require_once("../app/Helper/extend/libweibo/saetv2.ex.class.php");
$o = new \SaeTOAuthV2( WB_AKEY , WB_SKEY );
$code_url = $o->getAuthorizeURL( WB_CALLBACK_URL);
return view('wblogin');
}
public function hrefwb(){
require_once("../app/Helper/extend/libweibo/saetv2.ex.class.php");
require_once("../app/Helper/extend/libweibo/config.php");
$o= new \SaeTOAuthV2( WB_AKEY , WB_SKEY , session()->get('_token'));
$data=$o->getAuthorizeURL(WB_CALLBACK_URL);
header('location:'.$data);
}
public function callbackwx(){
require_once("../app/Helper/extend/libweibo/saetv2.ex.class.php");
require_once("../app/Helper/extend/libweibo/config.php");
$obj = new \SaeTOAuthV2(WB_AKEY , WB_SKEY , session()->get('_token'));
$code = $_GET['code'];
$callback_url = "http://home.cn/callbackwx";
$keys["code"] = $code;
$keys["redirect_uri"] = $callback_url;
$a = $obj->getAccessToken('code',$keys);
$info = file_get_contents("https://api.weibo.com/2/users/show.json?access_token={$a['access_token']}&uid={$a['uid']}");
echo "<pre>";
var_dump($info);
// dd($info);
}
看起来很简答~~·但是调试过程中还是得花花时间,直接拷贝去用吧,SDK包在官网下,我这边就不浪费空间了,附上地址:
https://open.weibo.com/wiki/SDK
也做过QQ,微信等第三方登陆