【问题标题】:PHP Open URL and RedirectPHP 打开 URL 和重定向
【发布时间】:2013-03-11 21:32:45
【问题描述】:

我正在使用一个名为 ImpulsePay 的 SMS 支付系统,但只有安全方法,实际上提供了一个 URL。

Secure Method

如何实现它,以便给定的 URL 是一个链接,或者更好的是,重定向到付款页面?

最终,我希望原始网站具有“点击此处通过短信付款”,但在这个早期开发阶段,一些页面重定向不应该成为问题。

任何帮助,不胜感激。

【问题讨论】:

  • 你能用更好的方式解释一下吗?这个问题还是比较模棱两可的……

标签: php javascript html shopping-cart


【解决方案1】:

这段代码将用户重定向到一个页面: header('Location: http://www.example.com/');

但是,必须在发送任何输出之前调用此函数。

【讨论】:

    【解决方案2】:

    你可以使用

    //Redirect browser
    header('Location: http://www.example.com/');
    
    //File get contents
    $url = 'http://www.example.com/redireccionar.php';
    $page = file_get_contents($url);
    echo $page;
    
    //cURL
    $c = curl_init('http://www.example.com/redireccionar.php');
    curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
    $page = curl_exec($c);
    curl_close($c);
    echo $page;
    
    //http Client
    $url = 'http://www.example.com/redireccionar.php';
    require_once 'HTTP/Client.php';
    $client = new HTTP_Client();
    $client->get($url);
    $page = $client->currentResponse();
    echo $page['body'];
    

    【讨论】:

      【解决方案3】:

      查看该 URL,您似乎必须调用您发布的 URL 才能获得付款链接?我会使用 PHP cURL 绑定来获取该 URL 生成的内容。

      此处为示例,http://davidwalsh.name/curl-download

      然后使用 header() 重定向。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-11-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多