Php 标题功能赢得';t redirect,当我使用curl获取重定向url时
代码中更好地说明了这个问题:Php 标题功能赢得';t redirect,当我使用curl获取重定向url时,php,curl,http-headers,Php,Curl,Http Headers,代码中更好地说明了这个问题: <?php $ch = curl_init(); $url = 'http://google.com'; curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_HEADER, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_exec($ch); $result_header = curl_getinfo($ch); curl_c
<?php
$ch = curl_init();
$url = 'http://google.com';
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
$result_header = curl_getinfo($ch);
curl_close($ch);
header('Location '.$result_header['redirect_uri']);//Here regional version of google, in my case its http://google.ru.
?>
所以标题不起作用。如何解决这个问题?
谢谢
向阿尔比娜致意。您的代码中实际上有两个错误:
- 它应该是
,带有redirect\u url
,而不是l
i
- 缺少标题名称后的冒号
header('Location: '.$result_header['redirect_url']);
我重新检查了一下,是的,你是对的,我之前混淆了OAuth协议,所以使用redirect\u uri而不是redirect\u url。OAuth使用重定向uri作为令牌。非常感谢。