• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SendAuth类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.tencent.mm.sdk.modelmsg.SendAuth的典型用法代码示例。如果您正苦于以下问题:Java SendAuth类的具体用法?Java SendAuth怎么用?Java SendAuth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SendAuth类属于com.tencent.mm.sdk.modelmsg包,在下文中一共展示了SendAuth类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: handleIntent

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
private void handleIntent(Intent intent) {
    if (intent == null) {
        return;
    }
    SendAuth.Resp resp = new SendAuth.Resp(intent.getExtras());
    if (resp.errCode == BaseResp.ErrCode.ERR_OK) {

        //用户同意
        String code = resp.code;
        String state = resp.state;
        // 如果不是登录
        if (!"wechat_login".equals(state)) {
            finish();
        } else {
            //上面的code就是接入指南里要拿到的code
            getAccessTokenAndOpenId(code);
        }

    } else {
        finish();
    }
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:23,代码来源:WXEntryActivity.java


示例2: login

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
public void login(Callback callback) {
    IWXAPI iwxapi = init();
    if (iwxapi == null) {
        if (callback != null)
            callback.onFailed();
        return;
    }
    // 唤起微信登录授权
    SendAuth.Req req = new SendAuth.Req();
    req.scope = "snsapi_userinfo";
    req.state = "wechat_login";
    // 失败回调
    if (!iwxapi.sendReq(req) && callback != null) {
        callback.onFailed();
    } else {
        if (callback != null)
            callback.onSuccess();
    }
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:20,代码来源:OpenBuilder.java


示例3: onClick

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.btn_wx_login:
            if (MyApplication.isInstallWx) {
                btn_login.setText(R.string.wx_logining);
                SendAuth.Req req = new SendAuth.Req();
                req.scope = getString(R.string.scope);
                req.state = getString(R.string.state);
                MyApplication.api.sendReq(req);
            } else {
                CommonUtils.showToast(getApplicationContext(), getString(R.string.wx_not_install));
            }
            break;

        case R.id.tv_protocol:
            Intent intent = new Intent(IndexActivity.this, ProtocolActivity.class);
            startActivity(intent);
            break;
    }
}
 
开发者ID:JunGeges,项目名称:AliZhiBoHao,代码行数:22,代码来源:IndexActivity.java


示例4: requestOauthCode

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
/**
 * 第一步、获得授权的code
 */
public void requestOauthCode(IWXListener listener, String transaction) {
    if (!WXAPI.isWXAppInstalled()) {
        if (listener != null) {
            listener.wxUnInstall();
        }
        return;
    }
    //1.生成一个此链接的唯一标识,返回的时候会原封不动地返回回来
    Random random = new Random();
    int value = random.nextInt(1000) + 1;
    mTransaction = transaction;
    String state = mTransaction + value;
    //2.发出请求,获取code
    final SendAuth.Req req = new SendAuth.Req();
    req.scope = "snsapi_userinfo";
    req.state = state;
    req.transaction = mTransaction;
    WXAPI.sendReq(req);
}
 
开发者ID:pinguo-sunjianfei,项目名称:Android-Application-ZJB,代码行数:23,代码来源:WChatManager.java


示例5: onCreate

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.act_login);
    ButterKnife.inject(this);
    //1.初始化model
    mViewModel = new LoginModel();
    //2.注册RxBus(请求Oauth_code时候的回调)
    RxBusManager.register(this, EventConstant.KEY_WX_OAUTH_CODE, WeiXinEvent.LoginEvent.class)
            .subscribe(resp -> {
                SendAuth.Resp response = resp.getData();
                if (SendAuth.Resp.ErrCode.ERR_OK == response.errCode) {
                    Observable<WChatLoginInfo> observable = WChatManager.getInstance().login(response.code);
                    Subscription subscription = observable.subscribe(this::onWChatAuthorizeNext, this::onWChatError);
                    addSubscription(subscription);
                } else {
                    setLoginBtnStatus(false);
                }
            }, Logger::e);
}
 
开发者ID:pinguo-sunjianfei,项目名称:Android-Application-ZJB,代码行数:21,代码来源:LoginActivity.java


示例6: login

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
public void login(final Activity activity, Bundle pararms, final LoginCallback callback) {
	DebugLog.d(TAG, "login()");
	
	this.callback = callback;
	
	IWXAPI wxapi = MyApp.getApp().getWXAPI();
	if (!wxapi.isWXAppInstalled()) {
           //提醒用户没有安装微信
		String uninstalled = activity.getResources().getString(R.string.WeixinLogin_uninstalled);
		CustomToast.makeText(activity,uninstalled, 2000).show();
           return;
       }
	
	 SendAuth.Req req = new SendAuth.Req();
     req.scope = "snsapi_userinfo";
     req.state = "wechat_sdk_demo";
     wxapi.sendReq(req);
}
 
开发者ID:leleliu008,项目名称:Newton_for_Android_AS,代码行数:20,代码来源:WeixinLogin.java


示例7: onWechatLogin

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
/**
 * 微信授权登录
 */
@Click(R.id.llWechatLogin)
void onWechatLogin() {
  /*  Log.i("LoginActivity", "微信授权登录");
    //AbToastUtil.showToast(mContext,"功能正在完善开发中...");
    Config.dialog = ProgressDialog.show(mContext, "提示", "正在请求跳转....");
    SHARE_MEDIA platform = SHARE_MEDIA.WEIXIN;
    umShareAPI = UMShareAPI.get(mContext);
    umShareAPI.doOauthVerify(this, platform, umAuthListener);*/
    if (Contact.isWeixinAvilible(this)) {
        progressDialog = AbDialogUtil.showProgressDialog(mContext, Global.LOADING_PROGRESSBAR_ID, "登录中");
        mLlWechatLogin.setEnabled(false);
        IWXAPI api = WXAPIFactory.createWXAPI(this, "wx747d053fa471eb15", true);

        api.registerApp("wx747d053fa471eb15");
        SendAuth.Req req = new SendAuth.Req();
        req.scope = "snsapi_userinfo";
        req.state = "wechat_sdk_demo_test";
        api.sendReq(req);
    } else {
        ToastUtils.show(this, "请安装微信");
    }
}
 
开发者ID:bangqu,项目名称:eshow-android,代码行数:26,代码来源:LoginActivity.java


示例8: onResp

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
public void onResp(BaseResp resp) {
	Log.e(TAG, "onResp...");
	Log.i("Apptest", "onResp...");
	String code = null;
	switch (resp.errCode) {
	case BaseResp.ErrCode.ERR_OK:// 用户同意,只有这种情况的时候code是有效的
		code = ((SendAuth.Resp) resp).code;
		Log.i("Apptest", code);
		getResult(code);
		break;
	case BaseResp.ErrCode.ERR_AUTH_DENIED:// 用户拒绝授权
		Log.e("Apptest", "用户拒绝授权");
		break;
	case BaseResp.ErrCode.ERR_USER_CANCEL:// 用户取消
		Log.e("Apptest", "用户取消");
		break;

	default:// 发送返回

		break;
	}
	finish();
}
 
开发者ID:gizwits,项目名称:Gizwits-SmartBuld_Android,代码行数:25,代码来源:WXEntryActivity.java


示例9: login

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
/**
 * 发出登陆请求
 * @param context
 */
public static void login(Context context) {

    if (!isWXAPPInstalled(context)) {
        Helper.showToast("请安装微信客户端");
    } else {
        if (!mWXAPI.isWXAppSupportAPI()) {
            Helper.showToast( "请升级微信客户端,不支持api!");
        } else {
            SendAuth.Req req = new SendAuth.Req();
            req.scope = "snsapi_userinfo";
            req.state = "none";
            mWXAPI.sendReq(req);
        }
    }

}
 
开发者ID:Moearly,项目名称:ZeaApp,代码行数:21,代码来源:ThirdWeiXinLoginApi.java


示例10: authComplete

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
public static void authComplete(SendAuth.Resp resp) {

        switch (resp.errCode) {
            case BaseResp.ErrCode.ERR_OK:
                callback.onGetCodeSuccess(resp.code);
                break;
            case BaseResp.ErrCode.ERR_USER_CANCEL:
                callback.onCancel();
                break;
            case BaseResp.ErrCode.ERR_AUTH_DENIED:
                callback.onFailure(new Exception("BaseResp.ErrCode.ERR_AUTH_DENIED"));
                break;
        }
    }
 
开发者ID:elbbbird,项目名称:ESSocialSDK,代码行数:15,代码来源:WeChatSSOProxy.java


示例11: onResp

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
public void onResp(BaseResp resp) {
    if (resp instanceof SendAuth.Resp)
        WeChatSSOProxy.authComplete((SendAuth.Resp) resp);
    else if (resp instanceof SendMessageToWX.Resp)
        WeChatShareProxy.shareComplete((SendMessageToWX.Resp) resp);

    finish();
}
 
开发者ID:elbbbird,项目名称:ESSocialSDK,代码行数:10,代码来源:WXCallbackActivity.java


示例12: doLogin

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
public void doLogin(Activity activity, LoginListener listener, boolean fetchUserInfo) {
    final SendAuth.Req req = new SendAuth.Req();
    req.scope = SCOPE_USER_INFO;
    req.state = String.valueOf(System.currentTimeMillis());
    mIWXAPI.sendReq(req);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:WxLoginInstance.java


示例13: handleResult

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
public void handleResult(int requestCode, int resultCode, Intent data) {
    mIWXAPI.handleIntent(data, new IWXAPIEventHandler() {
        @Override
        public void onReq(BaseReq baseReq) {
        }

        @Override
        public void onResp(BaseResp baseResp) {
            if (baseResp instanceof SendAuth.Resp && baseResp.getType() == 1) {
                SendAuth.Resp resp = (SendAuth.Resp) baseResp;
                switch (resp.errCode) {
                    case BaseResp.ErrCode.ERR_OK:
                        getToken(resp.code);
                        break;
                    case BaseResp.ErrCode.ERR_USER_CANCEL:
                        mLoginListener.loginCancel();
                        break;
                    case BaseResp.ErrCode.ERR_SENT_FAILED:
                        mLoginListener.loginFailure(new Exception(INFO.WX_ERR_SENT_FAILED));
                        break;
                    case BaseResp.ErrCode.ERR_UNSUPPORT:
                        mLoginListener.loginFailure(new Exception(INFO.WX_ERR_UNSUPPORT));
                        break;
                    case BaseResp.ErrCode.ERR_AUTH_DENIED:
                        mLoginListener.loginFailure(new Exception(INFO.WX_ERR_AUTH_DENIED));
                        break;
                    default:
                        mLoginListener.loginFailure(new Exception(INFO.WX_ERR_AUTH_ERROR));
                }
            }
        }
    });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:35,代码来源:WxLoginInstance.java


示例14: login

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
public static void login(Context context, IWXCallback callback, SocialInfo info) {
    if (!SocialSSOProxy.isTokenValid(context)) {
        WeChatSSOProxy.callback = callback;
        SendAuth.Req req = new SendAuth.Req();
        req.scope = info.getWeChatScope();
        WeChat.getIWXAPIInstance(context, info.getWechatAppId()).sendReq(req);
    }
}
 
开发者ID:yangjie127,项目名称:ESSocialSDK-master,代码行数:9,代码来源:WeChatSSOProxy.java


示例15: auth

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
public void auth(Activity activity) {
    ShareType = ShareConstant.AUTH;
    api = WXAPIFactory.createWXAPI(activity, BuildConfig.WECHAT_APP_ID, true);
    api.registerApp(BuildConfig.WECHAT_APP_ID);

    SendAuth.Req req = new SendAuth.Req();
    req.scope = "snsapi_userinfo";
    req.state = "mengwo_wx_login";

    api.sendReq(req);
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:13,代码来源:ShareWechat.java


示例16: onEventMainThread

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(BaseRespEvent event) {
    if (ShareType == ShareConstant.SHARE) {
        this.onDestroy();
    }

    BaseResp baseResp = event.getBaseResp();
    if (baseResp.errCode == BaseResp.ErrCode.ERR_USER_CANCEL) {
        shareListener.onCancel(ShareType, platform);
        return;
    }

    if (ShareType == ShareConstant.AUTH) {
        SendAuth.Resp resp = (SendAuth.Resp) baseResp;
        if (TextUtils.isEmpty(resp.code)) {
            return;
        }
        this.code = resp.code;
    }

    switch (baseResp.errCode) {
        case BaseResp.ErrCode.ERR_OK:
            shareListener.onComplete(ShareType, platform, event);
            if (ShareType == ShareConstant.SHARE) {
                MyNetUtils.shareCount(App.getDefault(), contentId);
            }

            break;

        case BaseResp.ErrCode.ERR_USER_CANCEL:
            shareListener.onCancel(ShareType, platform);
            break;

        default:
            ShareException exception = new ShareException("被拒绝或者失败啦");
            shareListener.onException(ShareType, platform, exception);
            break;
    }

}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:41,代码来源:ShareWechat.java


示例17: authorize

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
public void authorize(Activity act, UMAuthListener listener) {
    if (TextUtils.isEmpty(this.WX_APPID) || TextUtils.isEmpty(this.WX_SECRET)) {
        Log.e("UMWXHandler", "Appid或者App secret为空,不能授权。请设置正确地Appid跟App Secret");
        return;
    }
    this.mAuthListener = listener;
    this.mAuthListener.onStart(this.isToCircle ? SHARE_MEDIA.WEIXIN_CIRCLE : SHARE_MEDIA
            .WEIXIN);
    this.isFromAuth = true;
    boolean isNotExpired = OauthHelper.isRefreshTokenNotExpired(act, SHARE_MEDIA.WEIXIN);
    if (!isNotExpired) {
        isNotExpired = OauthHelper.isRefreshTokenNotExpired(act, SHARE_MEDIA.WEIXIN_CIRCLE);
    }
    if (isNotExpired && this.mRefreshTokenAvailable) {
        String refreshToken = OauthHelper.getRefreshToken(act, SHARE_MEDIA.WEIXIN);
        if (TextUtils.isEmpty(refreshToken)) {
            refreshToken = OauthHelper.getRefreshToken(act, SHARE_MEDIA.WEIXIN_CIRCLE);
        }
        loadOauthData("https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=" + this
                .WX_APPID + "&grant_type=refresh_token&refresh_token=" + refreshToken);
        return;
    }
    SendAuth.Req req = new SendAuth.Req();
    req.scope = "snsapi_userinfo,snsapi_friend,snsapi_message";
    req.state = "none";
    this.mWXApi.sendReq(req);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:28,代码来源:UMWXHandler.java


示例18: auth

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
    public void auth(Activity activity, final AuthCallback callback) {
        mMmsApi = WXAPIFactory.createWXAPI(activity.getApplicationContext(), TENCENT_MMS_APP_ID, true);
        mMmsApi.registerApp(TENCENT_MMS_APP_ID);

//        activity.runOnUiThread(() -> {
            SendAuth.Req req = new SendAuth.Req();
            req.scope = WX_USERINFO_SCOPE;
            req.state = "crew_state_" + System.currentTimeMillis();
            mMmsApi.sendReq(req);
            Logger.d("UserSystem", "wechat sendReq");
//        });
    }
 
开发者ID:markzhai,项目名称:AndroidProjectFrom0,代码行数:14,代码来源:WechatAuth.java


示例19: onResp

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
public void onResp(BaseResp resp) {
	Log.e(TAG, "onResp...");
	Log.i("Apptest", "onResp...");
	SDKLog.d(TAG + "   onResp...");
	String code = null;
	switch (resp.errCode) {
	case BaseResp.ErrCode.ERR_OK:// 用户同意,只有这种情况的时候code是有效的
		code = ((SendAuth.Resp) resp).code;
		Log.i("Apptest", code);

		SDKLog.d(TAG + "   code..." + code);
		getResult(code);
		break;
	case BaseResp.ErrCode.ERR_AUTH_DENIED:// 用户拒绝授权
		Log.e("Apptest", "用户拒绝授权");
		SDKLog.d(TAG + "   用户拒绝授权...");
		break;
	case BaseResp.ErrCode.ERR_USER_CANCEL:// 用户取消
		Log.e("Apptest", "用户取消");
		SDKLog.d(TAG + "   用户取消...");
		break;

	default:// 发送返回

		break;
	}
	finish();
}
 
开发者ID:gizwits,项目名称:GOpenSource_AppKit_Android_AS,代码行数:30,代码来源:WXEntryActivity.java


示例20: auth

import com.tencent.mm.sdk.modelmsg.SendAuth; //导入依赖的package包/类
@Override
public boolean auth(boolean requestUserInfo) {
	if (!super.auth(requestUserInfo))
		return false;
	SendAuth.Req req = new SendAuth.Req();
	req.scope = "snsapi_userinfo";
	req.state = "wechat_sdk_demo_test";
	getPlatform().getApi().sendReq(req);
	return true;
}
 
开发者ID:Joy-Whale,项目名称:EasyShare,代码行数:11,代码来源:WechatAuth.java



注:本文中的com.tencent.mm.sdk.modelmsg.SendAuth类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TableIntegrityErrorHandler类代码示例发布时间:2022-05-21
下一篇:
Java ErrorCode类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap