本文整理汇总了PHP中SaeTOAuthV2::parseSignedRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP SaeTOAuthV2::parseSignedRequest方法的具体用法?PHP SaeTOAuthV2::parseSignedRequest怎么用?PHP SaeTOAuthV2::parseSignedRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SaeTOAuthV2
的用法示例。
在下文中一共展示了SaeTOAuthV2::parseSignedRequest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCallback
/**
* 授权页
*/
public function actionCallback()
{
// weibo POST
//从POST过来的signed_request中提取oauth2信息
if (!empty($_REQUEST["signed_request"])) {
$o = new SaeTOAuthV2(Yii::app()->params['WB_AKEY'], Yii::app()->params['WB_SKEY']);
$data = $o->parseSignedRequest($_REQUEST["signed_request"]);
if ($data == '-2') {
die('签名错误!');
} else {
$_SESSION['oauth2'] = $data;
}
}
//print_r($_SESSION['oauth2']);
if (empty($_SESSION['oauth2']["user_id"])) {
//若没有获取到access token,则发起授权请求
$this->render('auth');
} else {
//若已获取到access token,则加载应用信息
//print_r($_SESSION['oauth2']);
$c = new SaeTClientV2(Yii::app()->params['WB_AKEY'], Yii::app()->params['WB_SKEY'], $_SESSION['oauth2']['oauth_token'], '');
Yii::app()->session['api'] = $c;
$this->redirect('/');
//setcookie( 'weibojs_'.$o->client_id, http_build_query($_SESSION['oauth2']) );
}
}
示例2: die
<?php
session_start();
include_once 'lib/config.php';
include_once 'lib/saetv2.ex.class.php';
//从POST过来的signed_request中提取oauth2信息
if (!empty($_REQUEST["signed_request"])) {
$o = new SaeTOAuthV2(WB_AKEY, WB_SKEY);
$data = $o->parseSignedRequest($_REQUEST["signed_request"]);
if ($data == '-2') {
die('签名错误!');
} else {
$_SESSION['oauth2'] = $data;
}
}
//判断用户是否授权
if (empty($_SESSION['oauth2']["user_id"])) {
include "lib/auth.php";
exit;
} else {
$c = new SaeTClientV2(WB_AKEY, WB_SKEY, $_SESSION['oauth2']['oauth_token'], '');
}
?>
<!--=============================== AUTH之后的页面内容,AUTH之前的内容是/lib/auth.php ============================================-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!----------------------我自己的CSS------------------------------>
<link href="css/style.css" type="text/css" rel="stylesheet" />
<!---------------------个人CSS库结束----------------------------->