CURL和PHP重定向 [英] CURL and PHP Redirect
问题描述
大家好,
我有一个小卷曲功能,可以吐出一堆标题。
CURL代码是:
$ url =" http://blahblah.com?登录" ;;
$ ch = curl_init();
curl_setopt($ ch,CURLOPT_URL,$ url);
curl_setopt($ ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ ch,CURLOPT_USERAGENT,$ _SERVER [" HTTP_USER_AGENT"]);
curl_setopt($ ch,CURLOPT_REFERER,
" http:/ /blahblah.com/default.asp?v=");
curl_setopt($ ch,CURLOPT_VERBOSE,0);
curl_setopt($ ch,CURLOPT_HEADER,1) ;
curl_setopt($ ch,CURLOPT_POST,1);
curl_setopt($ ch,CURLOPT_POSTFIELDS,
" FormId = 0& Config = 0& RedirectURL = $ RedirectURL& Identi fication = $ UserID& Verification = $ Password& DB = $ DB& Rem emberLogon = 1& UseEnhancedContent = 1");
curl_setopt($ ch,CURLOPT_COOKIE JAR,''Ocookie.txt'');
$ content = curl_exec($ ch); #这将返回HTML
curl_close($ ch);
print $ content;
以上代码的HTML sspit是:
HTTP / 1.1 100继续服务器:Microsoft-IIS / 5。1日期:2006年3月17日星期五
00:14:25 GMT X-Powered-By:ASP .NET HTTP / 1.1 200 OK服务器:
Microsoft-IIS / 5。1日期:2006年3月17日星期五00:14:25 GMT X-Powered-By:
ASP .NET连接:关闭内容类型:text / html刷新:0;
URL = http://blahblah.com/default.asp?v = Set-Cookie:osaa = guest;
到期=星期一,2009年3月16日00:14:25 GMT; path = / Set-Cookie:
osab = guest;到期= 2009年3月16日星期一00:14:25 GMT; path = /
所有这些都与现有的HTML一起打印,上面写着上面的
卷曲代码。如何将现有页面重定向到标题中的一个
设置,确保传递整个标题
由curl代码吐出的信息?
谢谢
url =" http://blahblah.com?登录 ;
ch = curl_init();
curl_setopt(
ch,CURLOPT_URL,
Hi All,
I have a small curl function which spits out a bunch of headers.
The CURL Code is:
$url="http://blahblah.com?Logon";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
curl_setopt($ch, CURLOPT_REFERER,
"http://blahblah.com/default.asp?v=");
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS,
"FormId=0&Config=0&RedirectURL=$RedirectURL&Identi fication=$UserID&Verification=$Password&DB=$DB&Rem emberLogon=1&UseEnhancedContent=1");
curl_setopt ($ch, CURLOPT_COOKIEJAR, ''Ocookie.txt'');
$content = curl_exec ($ch); # This returns HTML
curl_close ($ch);
print $content;
The HTML sspit out by the above code is:
HTTP/1.1 100 Continue Server: Microsoft-IIS/5.1 Date: Fri, 17 Mar 2006
00:14:25 GMT X-Powered-By: ASP.NET HTTP/1.1 200 OK Server:
Microsoft-IIS/5.1 Date: Fri, 17 Mar 2006 00:14:25 GMT X-Powered-By:
ASP.NET Connection: close Content-Type: text/html Refresh: 0;
URL=http://blahblah.com/default.asp?v= Set-Cookie: osaa=guest;
expires=Monday, 16-Mar-2009 00:14:25 GMT; path=/ Set-Cookie:
osab=guest; expires=Monday, 16-Mar-2009 00:14:25 GMT; path=/
All this is printed along with the existing HTML on which the above
curl code is written. How do I redirect the existing page to the one
setup in the headers by making sure of passing the whole header
information which is spit out by the curl code?
Thanks
url="http://blahblah.com?Logon";
ch = curl_init();
curl_setopt(
ch, CURLOPT_URL,
这篇关于CURL和PHP重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!