我的Facebook应用程序在验证时会生成这样的网址
我需要使用正则表达式来提取=和&之间的部分。
http://mydomain.com/token.php#access_token=CAACZCwCGi5JABAFKTYg7X4g7N5eq0Npc6d9kFjn8LNhYdXAGBasbrAStsdRzDg7lQ2OCwhWZCNP73k5uGj6rtGh5ZBHPv3MniE74zYWgq7ls2tQaXFyOY1dhyQdBVm67Ok6Q1y32cUHTHCZAOeU7WZBSmaDksdfkZD&expires_in=5181223&code=AQDNbbH2cvM2pvjOO-P2luM8atGhhqlGDQDnpHteR3KiJ7DmuusFwfvnJgpr4xMph4z-xlQ52PaAIG4FjVKfdXiYm4rbHdTBIuGmKkGleoZUIuiETFNRKA5rOJaseoTod-n1wXg913LqJEupWt0dv0i_45pQlefrRiCFC8JCmcAZJOjz2Lwbt1pyHoxY7VCGoi7umlfeVN9OBs6tYpV97zO9h9fzNsLbpQSyY9k8veFR50Rfx7zCQBZKgIilcyQGe7x7mtbQfFMtQzqUnobmuuDnOTBiOL7mM028LS16sx4XIhYaqbPc1KBy5aZ-oe1dtpA
我们将调用此变量$ token
mydomain.com/token.php也有以下表格来使用令牌:
<form action="http://domain.com/run.php" method="post" id="form1">
<input type="hidden" name="token" value="<php echo $token; ?>" /></form>
<script language="JavaScript">
document.getElementById('form1').submit();</script>
$ token用于第二页(run.php)
我该怎么做
答案 0 :(得分:1)
这有帮助吗?
/\b(access_token=)(\w)*\b/gi
要回显提交的帖子值,只需$ _POST [“token”]。
答案 1 :(得分:0)
<?php
$url = 'http://mydomain.com/token.php#access_token=CAACZCwCGi5JABAFKTYg7X4g7N5eq0Npc6d9kFjn8LNhYdXAGBasbrAStsdRzDg7lQ2OCwhWZCNP73k5uGj6rtGh5ZBHPv3MniE74zYWgq7ls2tQaXFyOY1dhyQdBVm67Ok6Q1y32cUHTHCZAOeU7WZBSmaDksdfkZD&expires_in=5181223&code=AQDNbbH2cvM2pvjOO-P2luM8atGhhqlGDQDnpHteR3KiJ7DmuusFwfvnJgpr4xMph4z-xlQ52PaAIG4FjVKfdXiYm4rbHdTBIuGmKkGleoZUIuiETFNRKA5rOJaseoTod-n1wXg913LqJEupWt0dv0i_45pQlefrRiCFC8JCmcAZJOjz2Lwbt1pyHoxY7VCGoi7umlfeVN9OBs6tYpV97zO9h9fzNsLbpQSyY9k8veFR50Rfx7zCQBZKgIilcyQGe7x7mtbQfFMtQzqUnobmuuDnOTBiOL7mM028LS16sx4XIhYaqbPc1KBy5aZ-oe1dtpA';
parse_str(parse_url($url, PHP_URL_FRAGMENT), $params);
?>
<form action="http://domain.com/run.php" method="post" id="form1">
<input type="hidden" name="token" value="<?php echo htmlspecialchars($params['access_token']) ?>" /></form>
</form>
<script type= text/javascript>
document.getElementById('form1').submit();
</script>
您可以通过$_POST['token']
在run.php中使用此令牌(请参阅:http://www.php.net/manual/en/reserved.variables.post.php)