【问题标题】:PHP file_get_contents() failed to open stream errorPHP file_get_contents() 无法打开流错误
【发布时间】:2012-01-12 03:33:44
【问题描述】:

我正在尝试连接到 Amazon Flexible Payments 沙箱,并按照他们在文档中的说明创建了一个请求字符串。现在我正在尝试使用 file_get_contents() PHP 函数向他们的服务发送请求,但出现此错误:

[<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found\r\n in file_name.php on line 84

知道为什么会发生这种情况吗?

这是我要发送的网址:

https://authorize.payments-sandbox.amazon.com/cobranded-ui/actions/start?SignatureVersion=2&returnUrl=http%3A%2F%2Fwww.problemio.com%2Fproject.php%3Fproject_id%2FProject_name%3 &paymentReason=donation&callerReference=YourCallerReference&callerKey=not_shown&transactionAmount=4.0&pipelineName=SingleUse&Signature=not_shown_in_SO%3D%3D

【问题讨论】:

  • 你能用同样的方法打开其他网址吗?
  • @pritaeas 好点。我可以打开其他网址。通过打开,这意味着我想下载他们的输出,因为在我的日志中,我得到了我尝试访问的页面的输出。所以也许我需要一个不同的功能,实际上将浏览器带到新页面。
  • 如果您只是将此 URL 复制并粘贴到浏览器中会怎样?你也有404吗?
  • PHP 手册中有一条关于 IIS 上 SSL 的警告,不确定是否适用。另外,我不确定 file_get_contents 如何处理重定向。使用 cUrl,您可以设置跟随它们的选项。 @Jakub,如果我在 Opera 上这样做,它会返回 200 页,并在 HTML 中显示警告。
  • @Jakub 如果我将其粘贴到浏览器中,我会收到一个差异错误:调用方输入异常:返回 URL 格式错误

标签: php amazon-web-services


【解决方案1】:

你有空格:…SignatureVersion=2 &amp;returnUrl=……Project_name%3 &amp;paymentReason…

【讨论】:

    【解决方案2】:

    您在 URL 中留下了一个空格,这会破坏它:

    .../start?SignatureVersion=2 &returnUrl=http%3A%2F%2Fwww.problemio.c...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-24
      • 1970-01-01
      • 2015-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-02
      • 2017-03-15
      相关资源
      最近更新 更多