Home >Backend Development >PHP Tutorial >sina微博oAuth phpSDK callback.php取不到$_SESSION['keys']!该如何处理

sina微博oAuth phpSDK callback.php取不到$_SESSION['keys']!该如何处理

WBOY
WBOYOriginal
2016-06-13 10:35:46950browse

sina微博oAuth phpSDK callback.php取不到$_SESSION['keys']!!
如题 callback.php页面中
$o = new WeiboOAuth( WB_AKEY , WB_SKEY , $_SESSION['keys']['oauth_token'] , $_SESSION['keys']['oauth_token_secret'] );

$last_key = $o->getAccessToken( $_REQUEST['oauth_verifier'] ) ;
报错!

经查错发现 $_SESSION['keys']不存在,但是我在index.php页面已经赋值了
$o = new WeiboOAuth( WB_AKEY , WB_SKEY );
$_SERVER["SCRIPT_URI"]='http://183.191.213.13:80';
$keys = $o->getRequestToken();
$aurl = $o->getAuthorizeURL( $keys['oauth_token'] ,false , $_SERVER['SCRIPT_URI'].'/callback.php');

$_SESSION['keys'] = $keys;
这里是有值的。。已经改了 utf-8 无bom编码 还是出错! 求解。。

------解决方案--------------------
要session_start
------解决方案--------------------
注意callback页面的域名和你访问session信息的页面的域名是否不同,需要设置SESSION COOKIE的domain。

Statement:
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