解决方案 »

  1.   

    可能是封装好的,你看下$resultStr 这个到底哪里调用了。应该能找到结果。
      

  2.   

    xml封装在$textTpl
           private function transmitText($object, $content, $flag = 0){
            $textTpl = "<xml>
                        <ToUserName><![CDATA[%s]]></ToUserName>
                        <FromUserName><![CDATA[%s]]></FromUserName>
                        <CreateTime>%s</CreateTime>
                        <MsgType><![CDATA[text]]></MsgType>
                        <Content><![CDATA[%s]]></Content>
                        <FuncFlag>%d</FuncFlag>
                        </xml>";
            $resultStr = sprintf($textTpl, $object->FromUserName, $object->ToUserName, time(), $content, $flag);
            return $resultStr;
        }
      

  3.   

    你只需要生成好微信规定的xml格式内容,微信服务端自然会返回结果。
      

  4.   

    附上代码供参考function xmlCurlPost($xmlData, $url, $timeoutMs=30000)
    {
        $ch = curl_init();
        $header[] = "Content-type: text/xml";//定义content-type为xml
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlData);
        curl_setopt($ch, CURLOPT_NOSIGNAL, 1);    //注意,毫秒超时一定要设置这个
        curl_setopt($ch, CURLOPT_TIMEOUT_MS, $timeoutMs);  //超时毫秒,cURL 7.16.2中被加入。从PHP 5.2.3起可使用
        $sContent = curl_exec($ch);
        $aStatus = curl_getinfo($ch);
        curl_close($ch);
        if(intval($aStatus["http_code"])==200){
            return trim($sContent);
        }else{
            return false;
        }
    }$postStr = file_get_contents("php://input");
    $return = xmlCurlPost($postStr, $url, $timeoutMs);