最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
解决php curl获取网页内容提示405 method not allowed状态码
时间:2022-06-24 23:24:35 编辑:袖梨 来源:一聚教程网
1.php curl ipv4使用例子
代码如下 | 复制代码 |
/** |
上面代码在ipv4是没有任何问题了,如果在了ipv6网站就会返回405 method not allowed状态码了,那么我们查看了php手册发现只要简单的修改一下即可。
以上为我编写的一个基本curl访问的方法,因为我这里需要通过使用IPv6的方式,所以加了相应的选项,相信大家能看的明白,平时经常用到的选项上面都有出现,大家根据需要摘取。
405/Method Not Allowed,表示不支持请求的方法,这个错误不常见。
导致403错误是要是由于curl默认是用post方式进行提交访问的,post方式在此域名下是没有权限的,如我在测试www.111com.net的时候就出现了此问题,在我修改为get的方式,并且增加了header头后,即可正常访问,个人推测,或许是亚马逊那边基本上都是采用get的方式,才会被认为是人为的点击,对post做了相应屏蔽。
ipv6增加了如下代码:
代码如下 | 复制代码 |
//设置Header头 |
命令行的形式为:
curl -v www.111com.net
IPV6下curl超时问题
代码如下 | 复制代码 |
$ch = curl_init(); |
注:curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4) 只有在php版本5.3及以上版本,curl版本7.10.8及以上版本时,以上设置才生效。
相关文章
- 归龙潮异域疾行怎么玩 10-01
- 光遇破晓季集体复刻怎么玩 10-01
- 敲棺盖修改器在哪下载 10-01
- 想要确保云网稳定运行离不开塔台管制员还是云网智能运维员的守护 10-01
- 蚂蚁庄园10月1日答案最新 10-01
- 支付宝蚂蚁森林神奇海洋9月30日答案 10-01