private void getAccessToken(String unionKey,String code) { VolleyUtil.get(SdkConfig.URL_WEIXIN_ACCESS_TOKEN, new ApiParams() .with("appid", SdkFactory.ShareConfig.sWeixin_app_Id) .with("secret", SdkFactory.ShareConfig.sWeixin_app_secret) .with("code", code) .with("grant_type", "authorization_code"), this, new HttpCallbackImpl(unionKey) { @Override public void onResponse(String url, String response) { final AccessTokenResult result = new JsonParser(response).parse(AccessTokenResult.class); if(!result.isOk()){ WeixinHelper.this.callbackWithRequestFailed(getUnionKey(), url, response); }else{ WeixinHelper.this.mAccessTokenResult = result; // getUserInfo getUserInfo(getUnionKey(), result); } } } ); }
private void getUserInfo(String unionKey,final AccessTokenResult result2) { VolleyUtil.get(SdkConfig.URL_WEIXIN_USER_INFO, new ApiParams() .with("access_token", result2.accessToken) .with("openid", result2.openid) , this, new HttpCallbackImpl(unionKey) { @Override public void onResponse(String url, String response) { final UserInfoResult result = new JsonParser(response).parse(UserInfoResult.class); if (!result.isOk()) { WeixinHelper.this.callbackWithRequestFailed(getUnionKey(), url, response); } else { if (!TextUtils.isEmpty(result.nickname)) { try { result.nickname = new String(result.nickname.getBytes("iso8859-1"), "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } result.accessToken = result2.accessToken; callbackWithUserInfo(getUnionKey(), result); } } } ); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mIntentExecutor = new IntentExecutor(); mHttpExecutor = new VolleyUtil.HttpExecutor(); mToaster = new Toaster(this); mViewHelper = new ViewHelper(getWindow().getDecorView()); onPreSetContentView(); setContentView(getlayoutId()); ButterKnife.inject(this); initView(); initData(savedInstanceState); }
public VolleyUtil.HttpExecutor getHttpExecutor(){ return mHttpExecutor; }
@Override public void reset() { mTaskManager.reset(); VolleyUtil.cancelAll(this); mCallbackMap.clear(); }