问题描述
- 求助,PHP与C++通信问题
-
C++写了一个HTTPRequest的类,访问服务器,通信也成功了,服务器那端是现有的PHP代码段, PHP那端调用"GLOBALS"的时侯$-POST()无法获取我传送过去的POST信息
这是PHP断读到的数据,所有数据都集中在Server中了,我发送的POST请求,post()中却是空的。
"GLOBALS": {
"GLOBALS": null,
"_POST": [], "_GET": [ ], "_COOKIE": [ ], "_FILES": [ ], "_SERVER": { "REDIRECT_STATUS": "200", "HTTP_HOST": "192.168.150.241", "HTTP_ACCEPT": "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint,text/html, application/xhtml+xml, */*", "HTTP_ACCEPT_CHARSET": "GBK,utf-8;q=0.7,*;q=0.3", "HTTP_ACCEPT_LANGUAGE": "en-us", "HTTP_USER_AGENT": "sky-socket/1.0", "CONTENT_LENGTH": "46", "CONTENT_TYPE": "application/x-www-form-urlencoded", "PATH": "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;D:\wamp\MySQL5\bin;C:\Program Files\VisualSVN Server\bin;", "SystemRoot": "C:\Windows", "COMSPEC": "C:\Windows\system32\cmd.exe", "PATHEXT": ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC", "WINDIR": "C:\Windows", "SERVER_SIGNATURE": "", "SERVER_SOFTWARE": "Apache/2.2.25 (Win32) PHP/5.3.9", "SERVER_NAME": "192.168.150.241", "SERVER_ADDR": "192.168.150.241", "SERVER_PORT": "80", "REMOTE_ADDR": "192.168.150.35", "DOCUMENT_ROOT": "D:/webroot/api", "SERVER_ADMIN": "1150601100@qq.com", "SCRIPT_FILENAME": "D:/webroot/api/index.php", "REMOTE_PORT": "61016", "REDIRECT_URL": "/home/test/index3", "GATEWAY_INTERFACE": "CGI/1.1", "SERVER_PROTOCOL": "HTTP/1.0", "REQUEST_METHOD": "POST", "QUERY_STRING": "", "REQUEST_URI": "/home/test/index3", "SCRIPT_NAME": "/index.php", "PATH_INFO": "test/index3", "PATH_TRANSLATED": "redirect:\index.php\home\test\index3\test\index3", "PHP_SELF": "/index.php/home/test/index3", "REQUEST_TIME": 1432009172 }, "_beginTime": 1432009172.1962, "_startUseMems": 371648, "_root": "\","_REQUEST":[],"_SESSION":[]},"_POST":[],"_GET":[],"_COOKIE":[],"_FILES":[],"_SERVER":{"REDIRECT_STATUS":"200","HTTP_HOST":"192.168.150.241","HTTP_ACCEPT":"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint, text/html, application/xhtml+xml, */*","HTTP_ACCEPT_CHARSET":"GBK, utf-8;q=0.7, *;q=0.3","HTTP_ACCEPT_LANGUAGE":"en-us","HTTP_USER_AGENT":"sky-socket/1.0","CONTENT_LENGTH":"46","CONTENT_TYPE":"application/x-www-form-urlencoded","PATH":"C: \Windows\system32;C: \Windows;C: \Windows\System32\Wbem;C: \Windows\System32\WindowsPowerShell\v1.0\;D: \wamp\MySQL5\bin;C: \ProgramFiles\VisualSVNServer\bin;","SystemRoot":"C: \Windows","COMSPEC":"C: \Windows\system32\cmd.exe","PATHEXT":".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC","WINDIR":"C: \Windows","SERVER_SIGNATURE":"","SERVER_SOFTWARE":"Apache/2.2.25(Win32)PHP/5.3.9","SERVER_NAME":"192.168.150.241","SERVER_ADDR":"192.168.150.241","SERVER_PORT":"80","REMOTE_ADDR":"192.168.150.35","DOCUMENT_ROOT":"D: /webroot/api","SERVER_ADMIN":"1150601100@qq.com","SCRIPT_FILENAME":"D: /webroot/api/index.php","REMOTE_PORT":"61016","REDIRECT_URL":"/home/test/index3","GATEWAY_INTERFACE":"CGI/1.1","SERVER_PROTOCOL":"HTTP/1.0","REQUEST_METHOD":"POST","QUERY_STRING":"","REQUEST_URI":"/home/test/index3","SCRIPT_NAME":"/index.php","PATH_INFO":"test/index3","PATH_TRANSLATED":"redirect: \index.php\home\test\index3\test\index3","PHP_SELF":"/index.php/home/test/index3","REQUEST_TIME":1432009172},"_beginTime":1432009172.1962,"_startUseMems":371648,"_root":"\", "_REQUEST": [ ], "_SESSION": [ ] } 求帮忙~!谢谢
解决方案
可能是post的数据格式有问题。抓包一下c代码发出的http包,具体分析
解决方案二:
http请求发送格式如下:
GET /V2/730458/2149880/1428622663/index.html HTTP/1.1
Host: cdn.optmd.com
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36
Referer: http://d169bbxks24g2u.cloudfront.net/ads/amzn-ads.html?size=300x250
Accept-Encoding: gzip, deflate, sdch
Accept-Language: zh-CN,zh;q=0.8
If-None-Match: "c028a-e5-51353275a5cc0"
If-Modified-Since: Thu, 09 Apr 2015 23:39:07 GMT
时间: 2024-10-03 00:59:28