微信客服消息提醒:
publicstaticvoidtest (string OpenID ) throws Exception{。
strJson =''msgtype':'text ',';
strJson =''text':{ ';
strJson =''content': '在这里写下你要出示的信息! ' ';
strJson ='}} ';
post(URL,strJson );
}
publicstaticvoidpost(stringURL,String json )。
try{
//s.setcontentencoding(utf-8 );
s.set content type (application/JSON );
post.setentity(s );
RES.get statusline (.get status code )==HttpStatus.SC_OK ) ) )
}
}catch(exceptione ) {
thrownewruntimeexception(e );
}
}
publicclassgetweixinaccesstoken {
public static String getToken ()
try{
http客户端http客户端=new http客户端(;
getmethodgetmethod=newgetmethod (URL;
int execute=http client.execute method (get method;
getresponse=get method.getresponsebodyasstring (;
}catch(ioexceptione ) {
e .打印任务跟踪(;
}
jsonobjectjson=JSON object.from object (getresponse );
return JSON.getstring (access _ token );
}
}