curl_init raw传递json参数
protected function curl_vm_record($url, $platform, $authorization, $jsonStr)
{
$ch = curl_init();
curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt( $ch, CURLOPT_USERAGENT , 'LEE' );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 20 );
curl_setopt( $ch, CURLOPT_TIMEOUT , 20);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER , TRUE );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Platform:'.$platform,
'Authorization:'.$authorization,
'Content-Length:' . strlen($jsonStr)
)
);
curl_setopt( $ch , CURLOPT_POST , TRUE );
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);
curl_setopt( $ch , CURLOPT_URL , $url );
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch); return array($httpCode, $response);
}
$data = array('id' => $id, 'isCheck' => $isCheck);
$url = '';
$platform = 101;
$authorization = $token;
$postdata = array('url'=>$url,'platform'=>$platform,'authorization'=>$authorization,'data'=>$data);
logfile(print_r($postdata, true), 'logfile');
$result = $this->curl_vm_record($url, $platform, $authorization,json_encode($data));
logfile(print_r($result, true), 'logfile');
curl_init raw传递json参数的更多相关文章
- WebApi传递JSON参数
开发过程中经常进行JSON的传递,在WebApi中传递JSON字串时,会发现服务器端接收到不参数值,看下面代码 服务端: public void Post([FromBody]string value ...
- Spring MVC(七)--传递JSON参数
有时候参数的传递还需要更多的参数,比如一个获取用户信息的请求中既有用户ID等基本参数,还要求对查询结果进行分页,针对这种场景,一般都会将分页参数封装成一个对象,然后将它和基本参数一起传给控制器,为了控 ...
- c# HttpWebRequest 模拟HTTP post 传递JSON参数
//HTTP post JSON 参数 private string HttpPost(string Url, Object ticket) { ...
- curl 使用 post 请求,传递 json 参数,下载文件
curl -X POST http://ip:8888/nacos/v1/cs/file/download -H "Accept: application/octet-stream" ...
- 原生态ajax 传递json参数到服务器端
案例说明:通过ajax将用户名和密码以json形式传递给服务器端,然后服务器端接受数据,进行处理返回json数据到前端 首先,在客户端,通过JavaScript脚本将页面表单数据封装成JSON格式.L ...
- HighChart 体验之旅 (后台传递JSON参数和数据的方法)
转自:http://www.cnblogs.com/daviddai/archive/2013/04/12/Highchart.html 官网:http://www.highcharts.com/ 中 ...
- ajax传递json参数
var pros = []; for(var i = 1; i <= 2; i++) { var obj = {}; obj.id = i; obj.age = i*20; pros = pro ...
- @JsonInclude(Include.NON_NULL) resttemplate 传递实体参数时 序列化为json时 空字符串不参与序列化
@JsonInclude(Include.NON_NULL) resttemplate 传递实体参数时 序列化为json时 空字符串不参与序列化 https://www.cnblogs.com/sup ...
- SpringBoot传递单一参数时@RequestParam和@RequestBody的区
用SpringBoot框架做项目时,经常需要前端给后端传递参数,如果需要多条参数,通常的做法是把这些参数封装为一个对象来传递,前端用POST方式调用.但有时会遇到后端只需要一条参数(比如一个Strin ...
随机推荐
- python3—廖雪峰之练习(三)
列表生成式练习 请修改列表生成式,通过添加if语句保证列表生成式能正确执行: L1 = ['Hello', 'World', 18, 'Apple', None] L2 = [] for x in L ...
- Linux文档整理之【Nginx安装Docker】
这次整理的文档是Docker安装 先说明下我用的系统是Linux Centos,不同的Linux版本差别不大. 1.安装依赖包 sudo yum install -y yum-utils device ...
- maven的概念模型
maven包含了一个项目对象模型(project object model),一组标准集合,一个项目生命周期(project lifecycle),一个依赖管理系统(dependency manage ...
- 吴恩达深度学习:2.1Logistic Regression逻辑回归及其损失函数
1.Logistic Regression是一个二元分类问题 (1)已知输入的特征向量x可能是一张图,你希望把它识别出来,这是不是猫图,你需要一个算法,可以给出预测值,更正式的y是一个概率,当输入特征 ...
- vue 源码分析
初始化 Data,props,event监听 beforCreated,Created 挂载 执行编译,首次渲染.创建和追加过程 编译 编译模块分为三个阶段:parse.optimize.gener ...
- [转载]Quartus ii 一些Warning/Eeror分析与解决
我会在此基础上继续添加 原文地址:ii 一些Warning/Eeror分析与解决">Quartus ii 一些Warning/Eeror分析与解决作者:yanppf 注:http:// ...
- zabbix 安装中文无法显示的问题
vi /usr/share/zabbix/include/locales.inc.php把zh_CN后面参数写true 然后去选择语言吧. 如果,去选择语言的时候,你发现还是不能选择....提示:Yo ...
- Andronov-Hopf bifurcation
地址:http://www.scholarpedia.org/article/Andronov-Hopf_bifurcation Andronov-Hopf bifurcation is the bi ...
- Composer\Downloader\TransportException ... Failed to enable crypto,failed to open stream: operation failed
failed to open stream: operation failed 错误详细信息: [Composer\Downloader\TransportException] The "h ...
- Linux shell 误操作
shell脚本在日常运维中是必不可少会应用到,下面是自己亲身经历过的一件事.会了定期清除日志,编写了一个shell脚本,内容如下: [root@centos- tmp]# more remote_lo ...