WechatMpClient

Struct WechatMpClient 

Source
pub struct WechatMpClient<T: SessionStore> { /* private fields */ }

Implementations§

Source§

impl<T: SessionStore> WechatMpClient<T>

Source

pub fn new<S: Into<String>>( appid: S, secret: S, ) -> WechatMpClient<SimpleStorage>

get the wechat client

Source

pub fn from_session<S: Into<String>>( appid: S, secret: S, session: T, ) -> WechatMpClient<T>

get the wechat client

Source

pub fn aes_key(self, aes_key: &str) -> Self

Source

pub fn token(self, token: &str) -> Self

Source

pub fn template_id(self, template_id: &str) -> Self

Source

pub async fn access_token(&self, force_refresh: bool) -> LabradorResult<String>

Source

pub async fn gen_shorten( &self, long_data: &str, expire_seconds: u64, ) -> LabradorResult<String>

短key托管 类似于短链API.
详情请见: https://developers.weixin.qq.com/doc/offiaccount/Account_Management/KEY_Shortener.html
Source

pub async fn fetch_shorten( &self, short_key: &str, ) -> LabradorResult<WechatMpShortKeyResponse>

短key解析 将短key还原为长信息。
详情请见: https://developers.weixin.qq.com/doc/offiaccount/Account_Management/KEY_Shortener.html
Source

pub async fn get_ticket( &self, ticket_type: TicketType, ) -> LabradorResult<String>

获得ticket,不强制刷新ticket.
链接
Source

pub async fn get_ticket_force( &self, ticket_type: TicketType, force_refresh: bool, ) -> LabradorResult<String>

获得ticket.
获得时会检查 Token是否过期,如果过期了,那么就刷新一下,否则就什么都不干
链接
Source

pub async fn create_jsapi_signature( &self, url: &str, ) -> LabradorResult<JsapiSignature>

创建调用jsapi时所需要的签名.

详情请见:链接
Source

pub async fn build_qr_connect_url( &self, redirect_url: &str, scope: &str, state: &str, ) -> LabradorResult<String>

构造第三方使用网站应用授权登录的url.
详情请见: 网站应用微信登录开发指南
URL格式为https://open.weixin.qq.com/connect/qrconnect?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect
Source

pub async fn get_callback_ip( &self, force_refresh: bool, ) -> LabradorResult<Vec<String>>

获取微信服务器的ip段
[文档](http://mp.weixin.qq.com/wiki/0/2ad4b6bfd29f30f71d39616c2a0fcedc.html)
Source

pub async fn get_jsapi_ticket( &self, force_refresh: bool, ) -> LabradorResult<String>

获得jsapi_ticket.
获得时会检查jsapiToken是否过期,如果过期了,那么就刷新一下,否则就什么都不干

详情请见:链接
Source

pub fn check_signature( &self, signature: &str, timestamp: i64, nonce: &str, ) -> LabradorResult<bool>

验证消息的确来自微信服务器.
详情(http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421135319&token=&lang=zh_CN)
Source

pub fn user(&self) -> WechatMpUser<'_, T>

用户相关服务

Source

pub fn oauth2(&self) -> WechatMpOauth2<'_, T>

Oauth2授权相关服务

Source

pub fn qrcode(&self) -> WechatMpQRCode<'_, T>

qrcode相关服务

Source

pub fn custom_service(&self) -> WechatMpCustomService<'_, T>

客服相关服务

Source

pub fn menu(&self) -> WechatMpMenu<'_, T>

菜单相关服务

Source

pub fn media(&self) -> WechatMpMedia<'_, T>

多媒体服务

Source

pub fn template_msg(&self) -> WechatMpTemplateMessage<'_, T>

模板消息服务

Source

pub fn subscribe_msg(&self) -> WechatMpSubscribeMessage<'_, T>

订阅消息服务

Source

pub fn wifi(&self) -> WechatMpWifi<'_, T>

Wifi服务

Source

pub fn ocr(&self) -> WechatMpOcr<'_, T>

OCR服务

Trait Implementations§

Source§

impl<T: Clone + SessionStore> Clone for WechatMpClient<T>

Source§

fn clone(&self) -> WechatMpClient<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + SessionStore> Debug for WechatMpClient<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for WechatMpClient<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for WechatMpClient<T>
where T: RefUnwindSafe,

§

impl<T> Send for WechatMpClient<T>
where T: Send,

§

impl<T> Sync for WechatMpClient<T>
where T: Sync,

§

impl<T> Unpin for WechatMpClient<T>
where T: Unpin,

§

impl<T> UnwindSafe for WechatMpClient<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more