php上传图片报400错误,PHP post请求返回400错误

我有以下类,它使用Web服务发送请求并获取JSON响应。

当我使用Chrome的Postman扩展程序尝试相同的操作时,我得到了一个很好的回复。

class RequestController {

function __construct() {

global $config;

$this->config = $config;

}

function send_request() {

$url = $this->config['GATEWAY']['url'] . 'getbyquery';

$json_data = '{"query":{"AllFields":true,"ConditionSetOperator":0,"ConditionSets":[],"Distinct":false,"Fields":["jay_alb","jay_levelms"],"Links":[],"Orders":[],"RecordType":"jay_lifeinsurance","Top":0}}';

$data = array($json_data);

$options = array(

'http' => array(

'header' => "Content-type: application/json\r\n",

'method' => 'POST',

'content' => http_build_query($data),

),

);

$context = stream_context_create($options);

print "

";

print_r($options);

print "

";

$result = file_get_contents($url, false, $context);

$data = json_decode($result);

var_dump($data);

}

}

然而,当我使用我的课时,我得到一个错误。

警告:file_get_contents(http://crm-gateway.premier.com.au/GatewayService.svc/getbyquery)[function.file-get-contents]:无法打开流:HTTP请求失败!在第32行的C:\ Program Files(x86)\ Apache Software Foundation \ Apache2.2 \ htdocs \ crm \ includes \ classes \ RequestController.php中需要HTTP / 1.1 411长度

你能指出我做错了吗?

谢谢,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值