Gaoming13\WechatPhpSdk\Utils\SHA1::getSHA1 PHP Method

getSHA1() static public method

用SHA1算法生成安全签名 生成微信消息体的签名
static public getSHA1 ( string $token, string $timestamp, string $nonce, string $encrypt_msg ) : boolean | string
$token string 票据
$timestamp string 时间戳
$nonce string 随机字符串
$encrypt_msg string 密文消息
return boolean | string
    static function getSHA1($token, $timestamp, $nonce, $encrypt_msg)
    {
        //排序
        try {
            $array = array($encrypt_msg, $token, $timestamp, $nonce);
            sort($array, SORT_STRING);
            $str = implode($array);
            return sha1($str);
        } catch (\Exception $e) {
            @error_log('getSHA1 Error: ' . $e->getMessage(), 0);
            return FALSE;
        }
    }

Usage Example

Ejemplo n.º 1
0
	 		 *	'media_id' => 'rVT43tfDwjh4p1BV2gJ5D7Zl2BswChO5L_llmlphLaTPytcGcguBAEJ1qK4cg4r_'
			 * ));
			 * ```
    		 */
            /**
    		 * 3 回复语音消息
    		 *
    		 * Examples:
             * ```
    		 * $wechat->reply(array(
	 		 * 	'type' => 'voice',
	 		 *	'media_id' => 'rVT43tfDwjh4p1BV2gJ5D7Zl2BswChO5L_llmlphLaTPytcGcguBAEJ1qK4cg4r_'
			 * ));
			 * ```
    		 */
            case 'voice':
                $xml = sprintf('<xml>
						<ToUserName><![CDATA[%s]]></ToUserName>
						<FromUserName><![CDATA[%s]]></FromUserName>
						<CreateTime>%s</CreateTime>
						<MsgType><![CDATA[voice]]></MsgType>
						<Voice>
						<MediaId><![CDATA[%s]]></MediaId>
						</Voice>
						</xml>', $this->message->FromUserName, $this->message->ToUserName, time(), $msg['media_id']);
                break;
                /**
    		 * 4 回复视频消息
    		 *
    		 * Examples:
             * ```
    		 * $wechat->reply(array(
	 		 *	'type' => 'video',
	 		 *	'media_id' => 'yV0l71NL0wtpRA8OMX0-dBRQsMVyt3fspPUzurIS3psi6eWOrb_WlEeO39jasoZ8',
	 		 *	'title' => '视频消息的标题',			//可选
	 		 *	'description' => '视频消息的描述'		//可选
			 * ));
			 * ```
    		 */
            /**
    		 * 4 回复视频消息
    		 *
    		 * Examples:
             * ```
    		 * $wechat->reply(array(
	 		 *	'type' => 'video',
	 		 *	'media_id' => 'yV0l71NL0wtpRA8OMX0-dBRQsMVyt3fspPUzurIS3psi6eWOrb_WlEeO39jasoZ8',