Home  >  Article  >  php教程  >  http post : Content-Type

http post : Content-Type

WBOY
WBOYOriginal
2016-06-06 20:11:46912browse

今天在使用http post(curl)获取一个数据的时候发现了问题,死活拿不到数据。获取永远为空。 场景是这样的:我向微信发起一个请求,QQ请求我的服务器,由我请求接口服务器。返回结果 但问题是,如果由微信直接请求接口服务器。一切正常。反而因为我做了一次

今天在使用http post(curl)获取一个数据的时候发现了问题,死活拿不到数据。获取永远为空。

场景是这样的:我向微信发起一个请求,QQ请求我的服务器,由我请求接口服务器。返回结果

但问题是,如果由微信直接请求接口服务器。一切正常。反而因为我做了一次中间层后。取不到数据了。

一点一点排查:

1、接口服务器的TransferMode是chunked。OK。我CURL换成1.0请求,结果还是空

2、换file_get_contents。。。一样是空。

3、排查微信请求的头。在我的服务器上把$_SERVER变量打印出来。结果。。意外的发现:Content-Type: text/xml,居然是这个?那我换成这个请求接口服务器试一下呢?居然真的成功了

遇到问题,果然是要一个个的排查啊。对方是java的服务器。可能会httprawbody做了一个强验证。所以。。。不象我们PHP可以拿到数据。先simplexml_load_string,不行?再json_decode,还不行?再用其他处理。。。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn