微信开发-获取access
Jun 07, 2016 pm 03:38 PMpublic static String getAccessToken() throws ClientProtocolException,IOException{String url = https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential;url = url + appid= + 你的公众平台 开发 appId + secret= + 你的公众平台appSecr
public static String getAccessToken() throws ClientProtocolException, IOException { String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential"; url = url + "&appid=" + 你的公众平台<strong>开发</strong>appId + "&secret=" + 你的公众平台appSecret; DefaultHttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); HttpResponse httpResponse; httpResponse = client.execute(httpGet); int code = httpResponse.getStatusLine().getStatusCode(); String strResult = EntityUtils.toString(httpResponse.getEntity(),WxData.CharSet); if (code == 200) { JSONObject jsonObject = JSONObject.fromObject(strResult); String token = jsonObject.getString("access_token"); System.out.println(token); } return null; }
每天接口访问次数为2000次,所以要保存到全局变量中,7200s的技能持续时间;
所需要的jar包
commons-beanutils
commons-collections
commons-httpclient
commons-lang
commons-logging
json-lib-2.3-jdk15
httpcore-4.2.2
httpmime-4.2.3
httpclient-cache-4.2.3
httpclient-4.2.3

人気の記事

人気の記事

ホットな記事タグ

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック











Windows 11 でバックグラウンド アプリケーションを無効にする方法_バックグラウンド アプリケーションを無効にする Windows 11 チュートリアル

「iPhone 16はWeChatをサポートしない可能性がある」との噂があり、中国のApple技術コンサルタントはアプリストア手数料についてテンセントと協議中と述べた

事情に詳しい関係者らは「WeChatはApple iPhone 16をサポートしていない可能性がある」と回答:噂は噂
