PHP模拟GET请求支付宝退款链接(未用sdk  自己拼接的请求链接与参数);

起初用file_get_contents();就报错 :failed to open stream: HTTP request failed! HTTP/1.1 505 HTTP Version Not Supported!!!

换成 curl模拟get 请求 返回值为空 没错 直接没报错 返回空字符串,,,以为curl参数设置不对,各种试到怀疑人生

接着继续 获取  $info = curl_getinfo($ch); 查看信息

发现 http_code 为 505 ,查到说是 不支持 HTTP/1.1的有(此处肯定不是该原因) 也有说请求格式不对 要 去除空格的

直接 对URL   preg_replace('# #','',$url) 再请求

接着  支付宝 又返回时间参数格式有错  也就是 yyy-MM-dd HH:mm:ss 中间的空格还不能没有

看到一篇文章  解决了该问题 : https://blog.csdn.net/bianb123/article/details/81557300

preg_replace('# #','%20',$url);

再回头  无论 file_get_contents(); 还是curl 都可成功请求, 期待已久的

"code":"10000","msg":"Success"

终于出来了

特此记录!

failed to open stream: HTTP request failed! HTTP/1.1 505 HTTP Version Not Supported的更多相关文章

  1. php file_get_contents失败[function.file-get-contents]: failed to open stream: HTTP request failed!解决

    在使用file_get_contents方法来获取远程文件时会出现 [function.file-get-contents]: failed to open stream: HTTP request ...

  2. 完美解决failed to open stream: HTTP request failed!(file_get_contents引起的)

    当使用php5自带的file_get_contents方法来获取远程文件的时候,有时候会出现file_get_contents(): failed to open stream: HTTP reque ...

  3. failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found

    failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found 一.总结 一句话总结:这里出现的问题是我在博客园删除了一篇文章,时 ...

  4. file_get_contents failed to open stream: HTTP request failed(一个字符决定成败)

    file_get_contents 开始成功了.后来不知怎么的就报错,调试半天没发现什么问题. 结果.里面多了一个"空格"就报错.去掉空格就好了,你们仔细找找吧.

  5. failed to open stream :HTTP request failed 解决方法

    用curl抓取,不要用file_get_contents(); 前者比后者效率高一点

  6. file_get_contents HTTP request failed! Internal Server Error

    使用file_get_contents报错 Severity: WarningMessage: file_get_contents(http://geetest.com:8000/select?gid ...

  7. 上传文件出错:org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly

    最近做一个web项目中有上传文件的功能,已经写出并在本地和部署到服务器上测试了好几个文件上传都没问题(我用的是tomcat).后来又上传了一个700多K的文件(前边的都是不足600K的,并且这个wor ...

  8. file_put_contents 错误:failed to open stream: Invalid argument 一种原因

    今天在测试nilcms系统的时候,出现了一个报错,导致缓存无法更新: file_put_contents(C:\UPUPW_AP5.4\vhosts\d.tv\NilCMS_APP\include_r ...

  9. Warning: file_put_contents(data.txt): failed to open stream: Permission denied in /Library/WebServer/Documents/test.php on line 22

    最近在学习PHP 在保存文件的时候报Warning: file_put_contents(data.txt): failed to open stream: Permission denied in ...

随机推荐

  1. Vue 数据持久化

    方法一:使用 localStorage 存储数据 window.localStorage.setItem(key,value) 方法二:使用 vuex-persistedstate插件 vuex 存在 ...

  2. Python性能分析工具Profile

    Python性能分析工具Profile 代码优化的前提是需要了解性能瓶颈在什么地方,程序运行的主要时间是消耗在哪里,对于比较复杂的代码可以借助一些工具来定位,python 内置了丰富的性能分析工具,如 ...

  3. 九、LaTex中的浮动体

    未利用浮动体:

  4. Java Annotation 刷课笔记(二)

    1.反射机制性能问题(安全检查) 1.1setAccessible 启用和禁用访问安全检查的开关,值为true,则指示反射的对象在使用时应该取消Java语言访问检查,值为false,则指示反射的对象应 ...

  5. 基于FastDFS在SpringBoot上的上传与下载

    方法: 1.在application.properties里设置参数,其中tracker-list是tracker的端口 fdfs.so-timeout= fdfs.connect-timeout= ...

  6. 10年前文章_eclipse下perl环境搭建

    eclipse下perl环境搭建1.Eclipse下安装perl插件Help -Software Updates…- Available .- Add Site… :http://e-p-i-c ...

  7. QueryDSL通用查询框架学习目录

    转载自恒宇的博客 https://www.jianshu.com/p/99a5ec5c3bd5

  8. window.location对象 获取页面地址

    window.location对象的属性: 属性 含义 值 location.protocol 协议 "http://"或"https://" location ...

  9. AGC007题解

    发现自己思维能力又跟不上了...做题有点吃力...所以回归AGC刷题计划... AGC040506都写了一部分题然后懒得补全了,所以从07开始做吧.大概是从C开始. C 这也太人类智慧了吧... 我先 ...

  10. MySQL数据库的自动备份与数据库被破坏后的恢复(3)

    [2] 当数据库被修改后的恢复方法 数据库被修改,可能存在着多方面的原因,被入侵.以及相应程序存在Bug等等,这里不作详细介绍.这里将只介绍在数据库被修改后,如果恢复到被修改前状态的方法. 具体和上面 ...