공용 함수 인덱스()
<code>{ $timeStamp =""; $nonce =""; $encrypt_type =''; $msg_sign =''; $encryptMsg =file_get_contents('php://input'); $result = $this->getVerify_Ticket($timeStamp,$nonce,$encrypt_type,$msg_sign,$encryptMsg); if($result){ echo "success"; } } </code>
//Component_verify_ticket 가져오기
<code>public function getVerify_Ticket($timeStamp,$nonce,$encrypt_type,$msg_sign,$encryptMsg){ $pc = new WXBizMsgCrypt(WxPayConfig::Token, WxPayConfig::EncodingAesKey, WxPayConfig::open_AppID); $xml_tree = new \DOMDocument(); $xml_tree->loadXML($encryptMsg); $array_e = $xml_tree->getElementsByTagName('Encrypt'); $encrypt = $array_e->item(0)->nodeValue; $format = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><Encrypt><![CDATA[%s]]></Encrypt></xml>"; $from_xml = sprintf($format, $encrypt); $msg = ''; $errCode = $pc->decryptMsg($msg_sign, $timeStamp, $nonce, $from_xml, $msg); if ($errCode == 0) { $xml = new \DOMDocument(); $xml->loadXML($msg); $array_e = $xml->getElementsByTagName('ComponentVerifyTicket'); $component_verify_ticket = $array_e->item(0)->nodeValue; DB::getDB()->delete("wechat_verifyticket",'uptime!=1'); DB::getDB()->insert("wechat_verifyticket",array( 'component_verify_ticket' => $component_verify_ticket, 'uptime' => time())); return true; }else{ DB::getDB()->delete("wechat_verifyticket",'uptime!=1'); DB::getDB()->insert("wechat_verifyticket",array( 'component_verify_ticket' => $errCode, 'uptime' => time())); return false; } } </code>
공용 함수 인덱스()
<code>{ $timeStamp =""; $nonce =""; $encrypt_type =''; $msg_sign =''; $encryptMsg =file_get_contents('php://input'); $result = $this->getVerify_Ticket($timeStamp,$nonce,$encrypt_type,$msg_sign,$encryptMsg); if($result){ echo "success"; } } </code>
//Component_verify_ticket 가져오기
<code>public function getVerify_Ticket($timeStamp,$nonce,$encrypt_type,$msg_sign,$encryptMsg){ $pc = new WXBizMsgCrypt(WxPayConfig::Token, WxPayConfig::EncodingAesKey, WxPayConfig::open_AppID); $xml_tree = new \DOMDocument(); $xml_tree->loadXML($encryptMsg); $array_e = $xml_tree->getElementsByTagName('Encrypt'); $encrypt = $array_e->item(0)->nodeValue; $format = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><Encrypt><![CDATA[%s]]></Encrypt></xml>"; $from_xml = sprintf($format, $encrypt); $msg = ''; $errCode = $pc->decryptMsg($msg_sign, $timeStamp, $nonce, $from_xml, $msg); if ($errCode == 0) { $xml = new \DOMDocument(); $xml->loadXML($msg); $array_e = $xml->getElementsByTagName('ComponentVerifyTicket'); $component_verify_ticket = $array_e->item(0)->nodeValue; DB::getDB()->delete("wechat_verifyticket",'uptime!=1'); DB::getDB()->insert("wechat_verifyticket",array( 'component_verify_ticket' => $component_verify_ticket, 'uptime' => time())); return true; }else{ DB::getDB()->delete("wechat_verifyticket",'uptime!=1'); DB::getDB()->insert("wechat_verifyticket",array( 'component_verify_ticket' => $errCode, 'uptime' => time())); return false; } } </code>
오류 메시지는 무엇인가요?