loadXML($xmltext); $array_e = $xml->getElementsByTagName('Encrypt'); $array_a = $xml->getElementsByTagName('ToUserName'); $encrypt = $array_e->item(0)->nodeValue; $tousername = $array_a->item(0)->nodeValue; return [0, $encrypt, $tousername]; } catch (\Exception $e) { return [NewsManager::ParseXmlError, null, null]; } } /** * @param $encrypt * @param $signature * @param $timestamp * @param $nonce * @return string */ public function generate($encrypt, $signature, $timestamp, $nonce) { $format = " %s "; return sprintf($format, $encrypt, $signature, $timestamp, $nonce); } }