【问题标题】:How to get a URL from a remote txt/php file and load that URL?如何从远程 txt/php 文件中获取 URL 并加载该 URL?
【发布时间】:2013-03-14 09:42:53
【问题描述】:

如何从另一个站点上的text/php 文件中获取URL,然后打开该URL 链接?

如果没有,则默认为 default.php

我可以访问这两个网站,

【问题讨论】:

  • 使用curl获取数据从站点B获取数据解析然后重定向到链接。

标签: php post curl get file-get-contents


【解决方案1】:

如果我理解正确,您希望站点 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);
?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-16
    • 2019-04-27
    • 2017-02-07
    相关资源
    最近更新 更多