curl http code 0
使用curl进行post请求后,接收status code ,结果返回的结果是0 ,但是请求返回的数据是正常的。
检查后发现是执行顺序问题:
$response = [
'statusCode' => curl_getinfo($curl , CURLINFO_HTTP_CODE),
'body' => curl_exec ($curl),
'curlErrorCode' => curl_errno ($curl),
];
由于后来改动结构,所以没在意 curl_exec的位置,直接调整就用了,所以在输出时,值一直是0
后来调整后就好了,也就是应该先执行$curl请求,然后才能获得请求的状态码等相关参数(没毛病),由于原来是放在数组外面接收的,所以不存在这个问题
$response = [
'body' => curl_exec ($curl),
'curlErrorCode' => curl_errno ($curl),
'statusCode' => curl_getinfo($curl , CURLINFO_HTTP_CODE),
];
所以还需要注意细节问题,理解原理性问题。
curl http code 0的更多相关文章
- 微软Visual Studio Code 0.8.0发布,新增多种主题
月30日,Build 开发者大会上,正式宣布了 Visual Studio Code 项目;并将其定义为:一个运行于 Mac OS X.Windows和 Linux 之上的,针对于编写现代 Web 和 ...
- [ios] 定位报错Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"
Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error ...
- IOS8解决获取位置坐标信息出错(Error Domain=kCLErrorDomain Code=0)(转)
标题:IOS8解决获取位置坐标信息出错(Error Domain=kCLErrorDomain Code=0) 前几天解决了在ios8上无法使用地址位置服务的问题,最近在模拟器上调试发现获取位置坐标信 ...
- IOS8解决获取位置坐标信息出错(Error Domain=kCLErrorDomain Code=0)
最近在模拟器上调试发现获取位置坐标信息的时候会报错,错误信息: didFailWithError: Error Domain=kCLErrorDomain Code=0 “The operation ...
- curl -x 127.0.0.1:80
curl -x ip:80 +网址 就相当于在本地hosts文件指定一个域名,具有优先访问权.(curl -x 127.0.0.1:80这个方法适用于生产环境的服务器来测试自己做为代理商访问是否正常) ...
- Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed.
地图定位 错误:使用CoreLocation获取地理位置信息,报错 Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be ...
- How do I solve the error: An error was encountered while running (Domain = LaunchServicesError, Code = 0) ?
How do I solve the error: An error was encountered while running (Domain = LaunchServicesError, Code ...
- Node.js and Forever “exited with code: 0”
CentOs 6.5 using root acount, I have a working Node.js Express app: root@vps [/home/test/node]# npm ...
- php日志报错child exited with code 0 after seconds from start
因为日志文件老是有这种提示: [27-May-2015 15:13:48] NOTICE: [pool www] child 3998 started [27-May-2015 15:13:59] N ...
随机推荐
- 撩课-Web大前端每天5道面试题-Day3
1. javascript的typeof返回哪些数据类型? 答案: undefined string boolean number symbol(ES6) Object Function 2. 列举3 ...
- 个人所得税计算java版
年关将至,该到了发年终奖的时候了.所以就到网上去找下,个税计算器,但是发现做的有点像病毒网站似的.所以计算结果也不太敢信,于是琢磨着,要不自己动手写一个个税计算器吧. 说干就干,先上国家税务局了解了下 ...
- JDK的安装与卸载
1.jdk 下载链接:http://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.html 2.在 ...
- USACO06DEC Milk Patterns——Solution
题目描述 Farmer John has noticed that the quality of milk given by his cows varies from day to day. On f ...
- SublimeText 批量清除空行
sublimeText 编辑器批量清除空行: 1.CTRL+H 打开 replace 功能 2.选择 Regular expression 功能 3.批两替换 点击replace All
- [HttpException (0x80004005): 应用程序已预编译,因此不允许使用目录“/App_Code/”。]
删除网站下的PrecompiledApp.config文件即可.
- Django——REST framework
1. 什么是REST REST与技术无关,代表的是一种软件架构风格,REST是Representational State Transfer的简称,中文翻译为“表征状态转移” REST从资源的角度类审 ...
- Chromebook 阿里云ECS 配置 jupyter Notebook
前言 新购入一台Chromebook Pixel ,为方便机器学习编程,用学生版的阿里云ECS搭建了jupyter Notebook 为减少下次踩坑,参考链接记录如下: 参考链接 阿里云使用笔记(一) ...
- HttpStatus
/* * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Vers ...
- 购物车redis存储结构