【发布时间】:2013-03-14 09:42:53
【问题描述】:
如何从另一个站点上的text/php 文件中获取URL,然后打开该URL 链接?
如果没有,则默认为 default.php
我可以访问这两个网站,
【问题讨论】:
-
使用curl获取数据从站点B获取数据解析然后重定向到链接。
标签: php post curl get file-get-contents
如何从另一个站点上的text/php 文件中获取URL,然后打开该URL 链接?
如果没有,则默认为 default.php
我可以访问这两个网站,
【问题讨论】:
标签: php post curl get file-get-contents
如果我理解正确,您希望站点 A 请求站点 B 上的 URL。站点 B 将响应一个 URL,并且您希望加载该 URL。您可以使用以下
<?
$url = 'http://www.siteb.com/givemeaurl.php';
$content = implode('', file($url));//
//$content now contains the response from site B. If its only the URL you can use it directly, else you need to parse the results
if (strlen($content)>0) {
//we have a value
$newurl = $content;
} else {
//no value
$newurl = 'default.php';
}
//no open the new site
header('Location: ' . $newurl);
?>
【讨论】: