一般不论get或post,都使用“参数名=参数值”这样的方式传递数据,我现在遇到一个问题,对方接口只接收无参数名的post数据,也就是post的时候,只发送数据,没有参数名。哪位有做过类似问题的,帮忙解决一下,谢谢

解决方案 »

  1.   

    PHP里不知道怎么搞,软件里倒是可以直接把数据post出去,不需要带参数名的
      

  2.   

    POST中URL不会出现参数, 应该是指这一种吧
      

  3.   

    稍等,发一段http拦截的数据上来,大家看一下应该能明白我说的
      

  4.   

    POST /abc.asp?username=abc&pwd=123456 HTTP/1.0
    Content-Type: text/html
    Content-Length: 302
    Connection: keep-alive
    Accept:text/html, */*#以下是Post的数据
    [101]
    aa=123
    bb=456
    [102]
    cc=232
    dd=4345
      

  5.   

    Ajax的写过,后台用$GLOBALS['HTTP_RAW_POST_DATA'] 或file_get_contents("php://input") 接收前台js:function Ajax(method,url,callBack,content)
    {
    url=urlRandom(url);
    var XmlHttp=createXmlHttp();
    if(callBack)
    {
    XmlHttp.onreadystatechange=function(){
    callBack(XmlHttp);
    //delete XmlHttp when complete;
    if(XmlHttp.readyState==4)
    {
    if(XmlHttp!=null) XmlHttp.abort();
    }
    }
    }
    try {
    XmlHttp.open(method,url,callBack?true:false);
    }
    catch(e){
    throw new Error(e);
    }
    if(method.toLowerCase()=="post"){
    XmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    }
    XmlHttp.send(content);
    }
    /* create XMLHttpRequest */
    function createXmlHttp()
    {
    var xmlHttp=null;
    if(window.ActiveXObject)
    {
    try{
    xmlHttp=new ActiveXObject("Microsoft.XmlHttp");
    }catch(e){
    xmlHttp=new ActiveXObject("MSXML2.XmlHttp");
    }
    }
    else if(window.XMLHttpRequest)
    {
    xmlHttp=new XMLHttpRequest();
    }
    return xmlHttp;
    }
    function urlRandom(url){
    if(url.indexOf("?")==-1) url=url+"?rid="+Math.random();
    else url=url+"&rid="+Math.random();
    return url;
    }
    向后台传递无参数的post值就是:var content="测试数据";
    Ajax("post","后台页面",callBack,content);这样传的便是无参数的数据了.常规的post也应该差不多,就是不写name吧,如<textarea>测试数据</textarea>,然后提交(这个没测试过)
      

  6.   

    $ch = curl_init();     
    //设置URL,POST方式提交以及POST数据   
    curl_setopt($ch, CURLOPT_URL, $searchURL);   
    curl_setopt($ch, CURLOPT_POST,1);   
    curl_setopt($ch, CURLOPT_POSTFIELDS, "post数据");        
      
    $result = curl_exec($ch);  
    其实不用想的哪么复杂.