dotdx80642 2015-11-21 20:11
浏览 223
已采纳

php curl post缺少参数

I have a curl request to get some information about database and stuff, but since some user need to query many bases and most of them are not familiar with any kind of shell, we are trying to build a small page to e"xecute the query and be more user friendly

we got pretty much everything working (form and stuff) but we got really figure how to build the uery in php

here is the original working curl request we made:

curl -s - X POST -H 'Content-type:application/json' -H 'Accept:application/json' -d '{"param1":"value1","param2":"value2"} -k https:myurl -u user:password

and here is the code with the request we are trying to build:

<?php
$data = array('param1' => 'value1',
              'param2' => 'value2'
             );
$ch = curl_init();
$url = "https://myurl";
curl_setopt($ch, curlopt_url, $url);
curl_setopt($ch,curlopt_userpwd, "user:password" );
curl_setopt($ch,curlopt_post, 1);
curl_setopt($ch,curlopt_postfuelds, $data);
curl_setopt($ch,curlopt_returntransfer, true);
curl_setopt($ch,curlopt_ssl_verifypeer, false);
curl_setopt($ch,curlopt_httpheader,
    array ("Content-type:application/json"));
$output = curl_exec($ch);

curl_close($ch); 

I cannot really figure whats wrong? can you help me? I rather not use shell_exec with the curl inside because the server hosting is on windows, and we don't have curl.exe available

thanks

  • 写回答

1条回答 默认 最新

  • duanchun1852 2015-11-21 22:07
    关注

    You have a typo: curlopt_postfuelds should be curlopt_postfields

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建