rust
use weixin_rust::agent;//引入应用模块
fn main(){
//由于access_token是内部自动维护的,需要定时更新,所以ag必须是mut 可变的
let mut ag= agent::Agent::new("corpid".to_string(),"agent_secret".to_string());
ag.fresh_token();//这个方法一般情况下是不需要手动调用的。只有在刚new出来的agent的情况下才需要。
println!("token={}",ag.get_access_token());//这个方法额外提供的,返回的是&str
}
```rust use weixin_rust::agent;
fn main(){
let mut ag= agent::Agent::new("corpid".tostring(),"agentsecret".tostring());
let r=ag.getapidomainip();//所有接口方法内部会自动刷新accesstoken
println!("{}",r["iplist"]);
//注意:所有接口返回的类型都是:Result
use weixin_rust::agent;
fn main(){
let mut ag= agent::Agent::new("corpid".to_string(),"agent_secret".to_string());
let r=ag.openuserid_to_userid(json!"{
"open_userid_list":["xxx", "yyy"],
"source_agentid":100001
}");
}
```rust use weixinrust::agent; use weixinrust::mail_list;
fn main(){ let mut ag= agent::Agent::new("corpid".tostring(),"agentsecret".tostring()); let mut userservice=ag.getuserservice();//获取用户服务对象 let ur=userservice.getuser(String::from("123456")); println!("{:?}",ur); } ```