2013-10-06 42 views
2

問題在代碼中更好地說明:頭功能不會重定向,當我使用捲曲得到重定向URL

<?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. 
?> 

所以頭將無法正常工作。如何解決這個問題呢? 謝謝。 祝好Albina。

回答

0

實際上有兩個錯誤在你的代碼:

  • 應該redirect_url,與l,不是i
  • 頭名稱後面的冒號是缺少

糾正它應該是

header('Location: '.$result_header['redirect_url']); 
+0

我重新檢查,是啊喲呃對,我在使用redirect_uri而不是redirect_url之前,與OAuth協議混淆了。 OAuth使用redirect_uri作爲標記。謝謝。 –