您好,欢迎访问一九零五行业门户网

php get数据问题请教

pc客户端通过crul post数据至后台:
http://218.204.14.50/test/?oldip=61.141.251.21&newip=61.141.251.25&urldata=http://detail.ju.taobao.com/home.htm?spm=601#/&agent=mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; sv1; qqdownload 732; .net4.0c; .net4.0e) &normal=100&error=102
后台php获取数据代码:
后台只能获取到oldip、newip、urldata数据,获取不到agent、normal、error数据,请问高手可能是什么原因?如何解决?
非常感谢!
回复讨论(解决方案) 既然是 post,那么怎么用 $_get 接受呢?
要用 $_post !
使用$_post之后,oldip、newip、urldata、agent、normal、error变量的数据都收不到了,这是为什么呢?
谢谢!
你把参数放到 url里面传递了,怎么能获取到数据呢!
$_request
$_post
$_get
都 记录下来,看看值在哪传的
具体传值代码怎么写?贴出来瞧瞧
嗯,你实际是 get 方式传值的
因为有 spm=601 #/
按约定 # 表示锚点,不会传往 文本服务器
所以其后的内容被截断了,所以你接收不到
而用 post 传值时就不会出现这种情况
贴出你的 curl 代码
明显你是用get方式传递的。
get 传递的参数需要用urlencode转一次。
http://218.204.14.50/test/?oldip=61.141.251.21&newip=61.141.251.25&urldata=http://detail.ju.taobao.com/home.htm?spm=601#/&agent=mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; sv1; qqdownload 732; .net4.0c; .net4.0e) &normal=100&error=102
应该改为
echo 'http://218.204.14.50/test/?oldip='.urlencode('61.141.251.21').'&newip='.urlencode('61.141.251.25').'&urldata='.urlencode('http://detail.ju.taobao.com/home.htm?spm=601#/').'&agent='.urlencode('mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; sv1; qqdownload 732; .net4.0c; .net4.0e) ').'&normal=100&error=102';
http://218.204.14.50/test/?oldip=61.141.251.21&newip=61.141.251.25&urldata=http%3a%2f%2fdetail.ju.taobao.com%2fhome.htm%3fspm%3d601%23%2f&agent=mozilla%2f4.0+%28compatible%3b+msie+6.0%3b+windows+nt+5.1%3b+sv1%3b+qqdownload+732%3b+.net4.0c%3b+.net4.0e%29+&normal=100&error=102
谢谢xuzuning、fdipzone版主的回复
curl代码:
curl *curl;
curlcode res;
curl_global_init(curl_global_all);
curl = curl_easy_init();
if(curl) {
cstring url(http://218.204.14.50/test/?oldip=);
url += csoldip;
url += &newip=;
url += csnewip;
url += &urldata=;
url += csurldata;
url += &agent=;
url += csagent;
url += &normal=;
url += csnormal;
url += &error=;
url += cserror;
curl_easy_setopt(curl, curlopt_url, ct2a(url));
curl_easy_setopt(curl, curlopt_httpget);
res = curl_easy_setopt(curl, curlopt_useragent, tian_test); 
res = curl_easy_perform(curl);
if(curle_ok == res)
return true;
curl_easy_cleanup(curl);
}
curl_global_cleanup();
客户端使用urlencode转码之后,后台是不是还要解码?
谢谢!
你这是 c++ 还是 c#
有对应于 php urlencode 的函数吗?
如果有,则将 形如 url += csoldip; 的
改为形如 url += urlencode(csoldip); 的
url 编码后,php 端无需解码
哦,忘了写,客户端是c++,我试试。多谢!
urlencode之后还是获取不到agent、normal、error数据,但将urldata值置为test之后,就可以收到数据了,怀疑是不是$_get长度有限制,如果不用$_get、$_request,还有其它解决方案吗?谢谢!
get 方式有 2k 的上限
所以你这的该用 post 方式
http://www.baidu.com/s?wd=c%2b%2b+curl+post&ie=utf-8
urlencode之后还是获取不到agent、normal、error数据,但将urldata值置为test之后,就可以收到数据了,怀疑是不是$_get长度有限制,如果不用$_get、$_request,还有其它解决方案吗?谢谢!
$_get有2k的限制,改用post就好了。 谢谢xuzuning 、fdipzone版主的回复,客户端改用post之后,后台基本可以获取到数据了,但遇到了新的问题,再请教一下:
pc客户端vc ++ crul post数据至后台:
http://218.204.14.50/test/?oldip=61.141.251.21&newip=61.141.251.25&urldata=http://detail.ju.taobao.com/home.htm?uastk=8c3def7900&userid=301115#/&agent=mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; sv1; qqdownload 732; .net4.0c; .net4.0e) &normal=100&error=102
后台php代码:
oldip=$_post['oldip']; //结果:61.141.251.21
newip=$_post['newip']; //结果:61.141.251.25
agent=$_post['agent']; //结果:mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; sv1; qqdownload 732; .net4.0c; .net4.0e)
normal=$_post['normal']; //结果:100
error=$_post['error']; //结果:102
以上变量都能正确获取,但urldata获取有问题
urldata=$$_post['urldata']; //希望获取的内容:http://detail.ju.taobao.com/home.htm?uastk=8c3def7900&userid=301115#/
但实际上获取的内容:http://detail.ju.taobao.com/home.htm?uastk=8c3def7900,无法获取&userid=301115#/,可能是&号分割的问题,请问这种情况应该怎么处理?
你 
file_put_contents('test.txt', print_r($_post,1));
贴出 test.txt 的内容
使用urlencode已解决,再次感谢2位版主的帮助。谢谢!
其它类似信息

推荐信息