Java Code Examples for com.gizwits.opensource.appkit.utils.JsonUtils

The following examples show how to use com.gizwits.opensource.appkit.utils.JsonUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: GOpenSource_AppKit_Android_AS   Source File: WXEntryActivity.java    License: MIT License 4 votes vote down vote up
/**
 * 获取openid accessToken值用于后期操作
 * 
 * @param code
 *            请求码
 */
private void getResult(final String code) {
	new Thread() {// 开启工作线程进行网络请求
		public void run() {
			String path = "https://api.weixin.qq.com/sns/oauth2/access_token?appid="
					+ GosDeploy.setWechatAppID()
					+ "&secret="
					+ GosDeploy.setWechatAppSecret()
					+ "&code="
					+ code
					+ "&grant_type=authorization_code";
			try {
				JSONObject jsonObject = JsonUtils
						.initSSLWithHttpClinet(path);// 请求https连接并得到json结果
				if (null != jsonObject) {
					String openid = jsonObject.getString("openid")
							.toString().trim();
					String access_token = jsonObject
							.getString("access_token").toString().trim();
					Log.i(TAG, "openid = " + openid);
					Log.i(TAG, "access_token = " + access_token);

					GosUserLoginActivity.gizThirdAccountType = GizThirdAccountType.GizThirdWeChat;
					GosUserLoginActivity.thirdToken = access_token;
					GosUserLoginActivity.thirdUid = openid;

					Message msg = new Message();
					msg.what = GosUserLoginActivity.handler_key.THRED_LOGIN
							.ordinal();

					if (baseHandler != null) {
						baseHandler.sendMessage(msg);
					}

				}
			} catch (Exception e) {
				e.printStackTrace();
				SDKLog.d(TAG + "   异常捕获..." + e.toString());
			}
			return;
		};
	}.start();
}