簡體   English   中英

PHP:CURL可以遵循元重定向

[英]PHP: Can CURL follow meta redirects

CURL可以使用CURLOPT_FOLLOWLOCATION跟隨標題重定向,但是可以遵循元刷新重定向嗎?

謝謝

是的,但是您必須通過解析響應並查找看起來像的內容來自己完成:

<meta http-equiv="refresh" content="5;url=http://example.com/" />

服從<meta>刷新請求是瀏覽器方面的事情。 使用DOM解析在cURL為您提供的響應中使用適當的屬性查找<meta>標記。

如果您可以保證響應是有效的XML,您可以執行以下操作:

$xml = simplexml_load_file($cURLResponse);
$result = $xml->xpath("//meta[@http-equiv='refresh']");
// Process the $result element to get the relevant bit out of the content attribute

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM