developed according to Wechat"s documentation, it has been unsuccessful
document: https://mp.weixin.qq.com/wiki.
public function responseImage($postObj){
$xmltpl = "<xml>
<ToUserName>< ![CDATA[%s] ]></ToUserName>
<FromUserName>< ![CDATA[%s] ]></FromUserName>
<CreateTime>%s</CreateTime>
<MsgType>< ![CDATA[image] ]></MsgType>
<Image>
<MediaId>< ![CDATA[%s] ]></MediaId>
</Image>
</xml>";
$result = sprintf($xmltpl, $postObj->FromUserName, $postObj->ToUserName,time(),$postObj->MediaId);
return $result;
}
$postObj = simplexml_load_string($postStr, "SimpleXMLElement", LIBXML_NOCDATA);
error after sending picture: the official account service failed
the reply of the text message is correct, but it is not good for a single picture, it is in encrypted mode.
Warriors, please take a look. Is there anything wrong and how to solve it?
Thank you
public function responseText($postObj){
//
$content = $postObj -> Content;
$xmltpl = "<xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%s</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[%s]]></Content>
</xml>";
$result = sprintf($xmltpl, $postObj->FromUserName, $postObj->ToUserName, time(), $content);
return $result;
}
encryption code
//
if ($encrypt_type == "aes"){
$encryptMsg = ""; //
$errCode = $pc->encryptMsg($result, $timeStamp, $nonce, $encryptMsg);
$result = $encryptMsg;
}
echo $result;