void AuthResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result) { UnityEngine.Debug.Log("AuthResultHandler" + MiniJSON.jsonEncode(result)); if (state == ResponseState.Success) { _thirdOpenId = (string)result["openid"]; _thirdToken = (string)result["access_token"]; _thirdExpireTime = (int)(double)result ["expires_in"]; //获取用户其他信息 if (_loginType == NowAccount.eLoginType.LOGIN_TYPE_QQ) { ssdk.GetUserInfo(PlatformType.QQ); } else if (_loginType == NowAccount.eLoginType.LOGIN_TYPE_WX) { ssdk.GetUserInfo(PlatformType.WeChat); } } else if (state == ResponseState.Fail) { CommonUtil.Util.showDialog("温馨提示", "授权错误! error code = " + result["error_code"] + "; error msg = " + result["error_msg"]); } else if (state == ResponseState.Cancel) { CommonUtil.Util.showDialog("温馨提示", "您取消了登陆"); } }
/// <summary> /// 授权回调 /// </summary> /// <param name="reqID"></param> /// <param name="state"></param> /// <param name="type"></param> /// <param name="result"></param> void OnAuthResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result) { SQDebug.Log("caonima===" + reqID + " state=" + state + " type=" + type); if (state == ResponseState.Success) { SQDebug.Log("微信授权成功正在获取微信信息"); print("authorize success !" + "Platform :" + type); ssdk.GetUserInfo(type); } else if (state == ResponseState.Fail) { Global.Inst.GetController <NetLoadingController>().ShowLoading(false); Global.Inst.GetController <CommonTipsController>().CloseWindow(); SQDebug.Log("授权失败"); #if UNITY_ANDROID print("fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"]); #elif UNITY_IPHONE print("fail! error code = " + result["error_code"] + "; error msg = " + result["error_msg"]); #endif } else if (state == ResponseState.Cancel) { Global.Inst.GetController <NetLoadingController>().ShowLoading(false); Global.Inst.GetController <CommonTipsController>().CloseWindow(); SQDebug.Log("微信授权失败"); print("cancel !"); } }
private void Awake() { ssdk = GameObject.FindObjectOfType <ShareSDK>(); if (ssdk == null) { ssdk = UnityHelper.GetOrCreateComponent <ShareSDK>(this.gameObject); } ssdk.authHandler = OnAuthResultHandler; ssdk.showUserHandler = OnGetUserInfoResultHandler; //Listeners wechatLoginBtn.onClick.AddListener(() => { ssdk.DisableSSO(false); ssdk.GetUserInfo(PlatformType.WeChat); }); qqLoginBtn.onClick.AddListener(() => { ssdk.GetUserInfo(PlatformType.QQ); }); weiboLoginBtn.onClick.AddListener(() => { ssdk.GetUserInfo(PlatformType.SinaWeibo); }); }
// Use this for initialization void Start() { ShareContent content = new ShareContent(); content.SetText("this is a test string."); content.SetImageUrl("https://f1.webshare.mob.com/code/demo/img/1.jpg"); content.SetTitle("test title"); content.SetShareType(ContentType.Image); ssdk.shareHandler = ShareResultHandler; //Share by the menu ssdk.ShowPlatformList(null, content, 100, 100); /* * //share by the content editor * ssdk.ShowShareContentEditor(PlatformType.SinaWeibo, content); * * //share directly * ssdk.ShareContent(PlatformType.SinaWeibo, content); */ ssdk.authHandler = AuthResultHandler; ssdk.Authorize(PlatformType.SinaWeibo); ssdk.showUserHandler = GetUserInfoResultHandler; ssdk.GetUserInfo(PlatformType.SinaWeibo); }
public void getUserInfo(int platformType) { switch (platformType) { case 1: ssdk.GetUserInfo(PlatformType.QQ); break; case 2: ssdk.GetUserInfo(PlatformType.WeChat); break; default: break; } }
private void OnAuthResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result) { if (state == ResponseState.Success) { Debug.Log(result); ssdk.GetUserInfo(type); } else if (state == ResponseState.Fail) { #if UNITY_ANDROID Debug.Log("fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"]); #elif UNITY_IOS Debug.Log("fail! error code = " + result["error_code"] + "; error msg = " + result["error_msg"]); #endif Debug.Log("Authorize Error"); Debug.Log("fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"]); if (funcAuthrizeResult != null) { funcAuthrizeResult.Call(ResponseState.Fail); } //ShowLogin(); //_bWechartLogining = false; } else if (state == ResponseState.Cancel) { Debug.Log("cancel !"); Debug.Log("Authorize cancel"); if (funcAuthrizeResult != null) { funcAuthrizeResult.Call(ResponseState.Cancel); } //ShowLogin(); //_bWechartLogining = false; } }
void OnAuthResultHandler(int reqID, ResponseState state, PlatformType type, System.Collections.Hashtable result) { if (state == ResponseState.Success) { if (result != null && result.Count > 0) { print("authorize success !" + "Platform :" + type + "result:" + MiniJSON.jsonEncode(result)); } else { print("authorize success !" + "Platform :" + type); } ssdk.GetUserInfo(PlatformType.WeChat); } else if (state == ResponseState.Fail) { #if UNITY_ANDROID print("fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"]); #elif UNITY_IPHONE print("fail! error code = " + result["error_code"] + "; error msg = " + result["error_msg"]); #endif } else if (state == ResponseState.Cancel) { print("cancel !"); } }
void OnAuthResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result) { if (state == ResponseState.Success) { ssdk.GetUserInfo(PlatformType.WeChat); Debuger.Log("微信SDK调用成功!"); if (CallBack_AuthResult != null) { CallBack_AuthResult(true); } } else if (state == ResponseState.Fail) { Debuger.Log("微信SDK调用失败!"); #if UNITY_ANDROID #elif UNITY_IPHONE #endif if (CallBack_AuthResult != null) { CallBack_AuthResult(false); } } else if (state == ResponseState.Cancel) { Debuger.Log("微信SDK调用Cancel!"); if (CallBack_AuthResult != null) { CallBack_AuthResult(false); } } }
/** * 登录,提供给button使用 * */ public void login() { #if USE_DEBUG || UNITY_EDITOR debugLogin(); #else shareSdk.GetUserInfo(PlatformType.WeChat); #endif }
public static void weChatLoginGame() { ssdk.CancelAuthorize(PlatformType.WeChat); ssdk.GetUserInfo(PlatformType.WeChat); Debug.Log("weChatLogin"); //C#调取Lua内脚本函数 //LuaFramework.Util.CallMethod("MainSenceCtrl", "Awake"); //LuaFramework.Util.CallMethod("LoginCtrl", "Close"); }
public void OnDetailButtonClick() { if (ShareSDKManager.Instance.userPlat == PlatformType.SinaWeibo) { ssdk.GetUserInfo(PlatformType.SinaWeibo); } if (ShareSDKManager.Instance.userPlat == PlatformType.SMS) { Utility.MakeToast("手机注册用户无法完成此操作"); } }
public void AuthResultHandle(int reqID, ResponseState state, PlatformType type, Hashtable data) { if (state == ResponseState.Success) { shareSdk.GetUserInfo(PlatformType.WeChat); } else if (state == ResponseState.Fail) { TipsManagerScript.getInstance().setTips("微信登录失败"); } }
/// <summary> /// 授权登录回调 /// </summary> /// <param name="reqID"></param> /// <param name="state"></param> /// <param name="type"></param> /// <param name="data"></param> void OnAuthResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable data) { if (state == ResponseState.Success) { ssdk.GetUserInfo(PlatformType.WeChat); } else if (state == ResponseState.Fail) { Debug.Log("授权失败"); print("fail! throwable stack = " + data["stack"] + "; error msg = " + data["msg"]); //GameData.ResultCodeStr = "fail! throwable stack = " + data["stack"] + "; error msg = " + data["msg"]; //UIManager.Instance.ShowUiPanel(UIPaths.ShowStringDialog, OpenPanelType.MinToMax); } }
// 账号回调 void GetUserInfoResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result) { if (state == ResponseState.Success) { print("get user info result :"); print(MiniJSON.jsonEncode(result)); ssdk.GetUserInfo(PlatformType.WeChat); } else if (state == ResponseState.Fail) { print("fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"]); } else if (state == ResponseState.Cancel) { print("cancel !"); } }
void AuthResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result) { if (state == ResponseState.Success) { //token = (string)result["token"]; //授权成功的话,获取用户信息 shareSdk.GetUserInfo(type); //text.tishi ="正在授权"; } else if (state == ResponseState.Fail) { //text.tishi =" 授权失败"; print("fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"]); } else if (state == ResponseState.Cancel) { } }
//授权结果回调 void AuthResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result) { if (state == ResponseState.Success) { message.text = ("authorize success !"); //授权成功的话,获取用户信息 ssdk.GetUserInfo(type); } else if (state == ResponseState.Fail) { message.text = ("fail! error code = " + result["error_code"] + "; error msg = " + result["error_msg"]); } else if (state == ResponseState.Cancel) { message.text = ("cancel !"); } }
void OnAuthResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result) { if (state == ResponseState.Success) { //授权成功的话,获取用户信息 ssdk.GetUserInfo(type); //获取用户授权信息 GetAuthInfo(type); } else if (state == ResponseState.Fail) { #if UNITY_ANDROID print("fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"]); #elif UNITY_IPHONE print("fail! error code = " + result["error_code"] + "; error msg = " + result["error_msg"]); #endif } else if (state == ResponseState.Cancel) { print("cancel !"); } }
private static void OnAuthResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result) { int platformType = ThirdPlatformTool.fromPlatformType(type); if (state == ResponseState.Success) { if (result != null && result.Count > 0) { Debug.Log("authorize success !" + "Platform :" + type + "result:" + MiniJSON.jsonEncode(result)); } else { Debug.Log("authorize success !" + "Platform :" + type); } _SSDK.GetUserInfo(type); } else if (state == ResponseState.Fail) { #if UNITY_ANDROID Debug.Log("fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"]); #elif UNITY_IPHONE Debug.Log("fail! error code = " + result["error_code"] + "; error msg = " + result["error_msg"]); #endif if (_AuthorLuaFunc != null) { _AuthorLuaFunc.Call((int)ThirdResponseState.Fail, "授权失败", platformType); } } else if (state == ResponseState.Cancel) { Debug.Log("cancel !"); if (_AuthorLuaFunc != null) { _AuthorLuaFunc.Call((int)ThirdResponseState.Cancel, "授权取消", platformType); } } }
public void Share(int type) { ssdk = gameObject.GetComponent <ShareSDK>(); ssdk.shareHandler = ShareResultHandler; ShareContent content = new ShareContent(); content.SetText("Play Pusoy online with me! Click to join my table! "); content.SetUrl("https://www.unlipoker.com"); content.SetTitle("Unlipoker"); content.SetShareType(ContentType.Auto); ssdk.GetUserInfo(PlatformType.FacebookMessenger); switch (type) { case 0: ShareFacebook(content); break; case 1: ShareMessenger(content); break; } }
void OnGUI() { GUI.skin = demoSkin; float scale = 1.0f; if (Application.platform == RuntimePlatform.IPhonePlayer) { scale = Screen.width / 320; } //float btnWidth = 165 * scale; float btnWidth = Screen.width / 5 * 2; float btnHeight = Screen.height / 25; float btnTop = 30 * scale; float btnGap = 20 * scale; GUI.skin.button.fontSize = Convert.ToInt32(13 * scale); if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Authorize")) { print(ssdk == null); ssdk.Authorize(PlatformType.QQ); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Get User Info")) { ssdk.GetUserInfo(PlatformType.QQ); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Show Share Menu")) { ShareContent content = new ShareContent(); //(Android only) 隐藏九宫格里面不需要用到的平台(仅仅是不显示平台) //(Android only) 也可以把jar包删除或者把Enabl属性e改成false(对应平台的全部功能将用不了) String[] platfsList = { ((int)PlatformType.QQ).ToString(), ((int)PlatformType.Facebook).ToString(), ((int)PlatformType.TencentWeibo).ToString() }; content.SetHidePlatforms(platfsList); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); //(Android only) 针对Android绕过审核的多图分享,传图片String数组 String[] imageArray = { "/sdcard/test.jpg", "http://f1.webshare.mob.com/dimgs/1c950a7b02087bf41bc56f07f7d3572c11dfcf36.jpg", "/sdcard/test.jpg" }; content.SetImageArray(imageArray); content.SetTitleUrl("http://www.mob.com"); content.SetSite("Mob-ShareSDK"); content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://www.mob.com"); content.SetComment("test description"); content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); content.SetShareType(ContentType.Image); //不同平台分享不同内容 ShareContent customizeShareParams = new ShareContent(); customizeShareParams.SetText("Sina share content"); customizeShareParams.SetImageUrl("http://git.oschina.net/alexyu.yxj/MyTmpFiles/raw/master/kmk_pic_fld/small/107.JPG"); customizeShareParams.SetShareType(ContentType.Text); customizeShareParams.SetObjectID("SinaID"); content.SetShareContentCustomize(PlatformType.SinaWeibo, customizeShareParams); //优先客户端分享 // content.SetEnableClientShare(true); //使用微博API接口应用内分享 iOS only // content.SetEnableSinaWeiboAPIShare(true); //通过分享菜单分享 ssdk.ShowPlatformList(null, content, 100, 100); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Show Share View")) { ShareContent content = new ShareContent(); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); content.SetTitleUrl("http://www.mob.com"); content.SetSite("Mob-ShareSDK"); content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://www.mob.com"); content.SetComment("test description"); content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); content.SetShareType(ContentType.Image); ssdk.ShowShareContentEditor(PlatformType.SinaWeibo, content); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Share Content")) { ShareContent content = new ShareContent(); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); // content.SetTitleUrl("http://www.mob.com"); // content.SetSite("Mob-ShareSDK"); // content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://qjsj.youzu.com/jycs/"); // content.SetComment("test description"); // content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); content.SetShareType(ContentType.Webpage); ssdk.ShareContent(PlatformType.WeChat, content); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Get Friends SinaWeibo ")) { //获取新浪微博好友,第一页,每页15条数据 print("Click Btn Of Get Friends SinaWeibo"); ssdk.GetFriendList(PlatformType.SinaWeibo, 15, 0); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Get Token SinaWeibo ")) { Hashtable authInfo = ssdk.GetAuthInfo(PlatformType.SinaWeibo); print("share result :"); print(MiniJSON.jsonEncode(authInfo)); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Close SSO Auth")) { ssdk.DisableSSO(true); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Remove Authorize ")) { ssdk.CancelAuthorize(PlatformType.SinaWeibo); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Add Friend ")) { //关注新浪微博 ssdk.AddFriend(PlatformType.SinaWeibo, "3189087725"); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "ShareWithContentName")) { Hashtable customFields = new Hashtable(); customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; //根据配置文件分享【本接口功能仅暂时支持iOS】 ssdk.ShareWithContentName(PlatformType.SinaWeibo, "ShareSDK", customFields); } btnWidth += 80 * scale; btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "ShowShareMenuWithContentName")) { Hashtable customFields = new Hashtable(); customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; //根据配置文件展示分享菜单分享【本接口功能仅暂时支持iOS】 ssdk.ShowPlatformListWithContentName("ShareSDK", customFields, null, 100, 100); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "ShowShareViewWithContentName")) { Hashtable customFields = new Hashtable(); //根据配置文件展示编辑界面分享【本接口功能仅暂时支持iOS】 customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; ssdk.ShowShareContentEditorWithContentName(PlatformType.SinaWeibo, "ShareSDK", customFields); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "SMS Authorize")) { ssdk.Authorize(PlatformType.SMS); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Share wxMiniProgram (ios only)")) { ShareContent content = new ShareContent(); content.SetTitle("MiniProgram"); content.SetText("test MiniProgram"); content.SetUrl("http://www.mob.com"); content.SetMiniProgramPath("pages/index/index"); content.SetThumbImageUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1527484508213&di=d993c2ca41fec50717d137718511120f&imgtype=0&src=http%3A%2F%2Fimg5.2345.com%2Fduoteimg%2FzixunImg%2Flocal%2F2017%2F05%2F03%2F14938009295612.jpg"); content.SetMiniProgramHdThumbImage("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1522154322305&di=7f4bf3d0803fe8c2c66c140f0a6ea0b4&imgtype=0&src=http%3A%2F%2Fa4.topitme.com%2Fo%2F201007%2F29%2F12803876734174.jpg"); content.SetMiniProgramUserName("gh_afb25ac019c9"); content.SetMiniProgramWithShareTicket(true); content.SetMiniProgramType(0); content.SetShareType(ContentType.MiniProgram); ShareContent shareContent = new ShareContent(); shareContent.SetShareContentCustomize(PlatformType.WeChat, content); ssdk.ShareContent(PlatformType.WeChat, shareContent); } }
void OnGUI() { GUI.skin = demoSkin; float scale = 1.0f; if (Application.platform == RuntimePlatform.IPhonePlayer) { scale = Screen.width / 320; } float btnWidth = 165 * scale; float btnHeight = 30 * scale; float btnTop = 20 * scale; float btnGap = 20 * scale; GUI.skin.button.fontSize = Convert.ToInt32(14 * scale); if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Authorize")) { print(ssdk == null); ssdk.Authorize(PlatformType.QQ); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Get User Info")) { ssdk.GetUserInfo(PlatformType.SinaWeibo); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Show Share Menu")) { ShareContent content = new ShareContent(); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); content.SetTitleUrl("http://www.mob.com"); content.SetSite("Mob-ShareSDK"); content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://www.mob.com"); content.SetComment("test description"); content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); content.SetShareType(ContentType.Image); //不同平台分享不同内容 ShareContent customizeShareParams = new ShareContent(); customizeShareParams.SetText("Sina share content"); customizeShareParams.SetImageUrl("http://git.oschina.net/alexyu.yxj/MyTmpFiles/raw/master/kmk_pic_fld/small/107.JPG"); customizeShareParams.SetShareType(ContentType.Text); customizeShareParams.SetObjectID("SinaID"); content.SetShareContentCustomize(PlatformType.SinaWeibo, customizeShareParams); //优先客户端分享 // content.SetEnableClientShare(true); //使用微博高级接口进行本地图片 文字 应用内分享 17年6月30日后需申请高级接口 // content.SetEnableAdvancedInterfaceShare(true); //通过分享菜单分享 ssdk.ShowPlatformList(null, content, 100, 100); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Show Share View")) { ShareContent content = new ShareContent(); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); content.SetTitleUrl("http://www.mob.com"); content.SetSite("Mob-ShareSDK"); content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://www.mob.com"); content.SetComment("test description"); content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); content.SetShareType(ContentType.Image); ssdk.ShowShareContentEditor(PlatformType.SinaWeibo, content); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Share Content")) { ShareContent content = new ShareContent(); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); // content.SetTitleUrl("http://www.mob.com"); // content.SetSite("Mob-ShareSDK"); // content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://qjsj.youzu.com/jycs/"); // content.SetComment("test description"); // content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); content.SetShareType(ContentType.Webpage); ssdk.ShareContent(PlatformType.WeChat, content); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Get Friends SinaWeibo ")) { //获取新浪微博好友,第一页,每页15条数据 print("Click Btn Of Get Friends SinaWeibo"); ssdk.GetFriendList(PlatformType.SinaWeibo, 15, 0); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Get Token SinaWeibo ")) { Hashtable authInfo = ssdk.GetAuthInfo(PlatformType.SinaWeibo); print("share result :"); print(MiniJSON.jsonEncode(authInfo)); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Close SSO Auth")) { ssdk.DisableSSO(true); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Remove Authorize ")) { ssdk.CancelAuthorize(PlatformType.SinaWeibo); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Add Friend ")) { //关注新浪微博 ssdk.AddFriend(PlatformType.SinaWeibo, "3189087725"); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "ShareWithContentName")) { Hashtable customFields = new Hashtable(); customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; //根据配置文件分享【本接口功能仅暂时支持iOS】 ssdk.ShareWithContentName(PlatformType.SinaWeibo, "ShareSDK", customFields); } btnWidth += 80 * scale; btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "ShowShareMenuWithContentName")) { Hashtable customFields = new Hashtable(); customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; //根据配置文件展示分享菜单分享【本接口功能仅暂时支持iOS】 ssdk.ShowPlatformListWithContentName("ShareSDK", customFields, null, 100, 100); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "ShowShareViewWithContentName")) { Hashtable customFields = new Hashtable(); //根据配置文件展示编辑界面分享【本接口功能仅暂时支持iOS】 customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; ssdk.ShowShareContentEditorWithContentName(PlatformType.SinaWeibo, "ShareSDK", customFields); } }
public void AutoLogin() { Utils.ShowMessagePanel("登陆中...", messagePanel); ssdk.GetUserInfo(PlatformType.WeChat); }
public void OnDetailButtonClick() { ssdk.GetUserInfo(PlatformType.SinaWeibo); }
void OnGUI() { GUI.skin = demoSkin; float scale = 1.0f; if (Application.platform == RuntimePlatform.IPhonePlayer) { scale = Screen.width / 320; } //float btnWidth = 165 * scale; float btnWidth = Screen.width / 5 * 2; float btnHeight = Screen.height / 25; float btnTop = 30 * scale; float btnGap = 20 * scale; GUI.skin.button.fontSize = Convert.ToInt32(13 * scale); if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Authorize")) { print(ssdk == null); ssdk.Authorize(PlatformType.Douyin); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Get User Info")) { ssdk.GetUserInfo(PlatformType.Douyin); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Show Share Menu")) { ShareContent content = new ShareContent(); // //(Android only) 隐藏九宫格里面不需要用到的平台(仅仅是不显示平台) // //(Android only) 也可以把jar包删除或者把Enabl属性e改成false(对应平台的全部功能将用不了) String[] platfsList = { ((int)PlatformType.QQ).ToString(), ((int)PlatformType.Facebook).ToString(), ((int)PlatformType.TencentWeibo).ToString() }; content.SetHidePlatforms(platfsList); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); //(Android only) 针对Android绕过审核的多图分享,传图片String数组 String[] imageArray = { "/sdcard/test.jpg", "http://f1.webshare.mob.com/dimgs/1c950a7b02087bf41bc56f07f7d3572c11dfcf36.jpg", "/sdcard/test.jpg" }; content.SetImageArray(imageArray); content.SetTitleUrl("http://www.mob.com"); content.SetSite("Mob-ShareSDK"); content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://www.mob.com"); content.SetComment("test description"); content.SetMusicUrl( "http://i.y.qq.com/v8/playsong.html?hostuin=0&songid=&songmid=002x5Jje3eUkXT&_wv=1&source=qq&appshare=iphone&media_mid=002x5Jje3eUkXT"); content.SetShareType(ContentType.Image); //不同平台分享不同内容 ShareContent customizeShareParams = new ShareContent(); customizeShareParams.SetText("Sina share content"); customizeShareParams.SetImageUrl( "http://git.oschina.net/alexyu.yxj/MyTmpFiles/raw/master/kmk_pic_fld/small/107.JPG"); customizeShareParams.SetShareType(ContentType.Text); customizeShareParams.SetObjectID("SinaID"); content.SetShareContentCustomize(PlatformType.SinaWeibo, customizeShareParams); //优先客户端分享 content.SetEnableClientShare(true); //使用微博API接口应用内分享 iOS only content.SetEnableSinaWeiboAPIShare(true); //通过分享菜单分享 ssdk.ShowPlatformList(null, content, 100, 100); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Show Share View")) { ShareContent content = new ShareContent(); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); content.SetTitleUrl("http://www.mob.com"); content.SetSite("Mob-ShareSDK"); content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://www.mob.com"); content.SetComment("test description"); content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); content.SetShareType(ContentType.Image); ssdk.ShowShareContentEditor(PlatformType.SinaWeibo, content); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Share Content")) { ShareContent content = new ShareContent(); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); //content.SetTitleUrl("http://www.mob.com"); //content.SetSite("Mob-ShareSDK"); //content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://qjsj.youzu.com/jycs/"); //content.SetComment("test description"); //content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); content.SetShareType(ContentType.Image); ssdk.ShareContent(PlatformType.QQ, content); // // 开发者要自己传入Activity 在9.0及其以上的系统 // // AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); // // AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity"); // // content.SetActivity(jo); // // Debug.Log("QQQ 测试传入的activity ==================>>> " + jo); // ShareContent content = new ShareContent(); // content.SetFilePath("/storage/emulated/0/douyin.mp4"); // content.SetShareType(ContentType.Video); // ssdk.ShareContent (PlatformType.Douyin, content); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Get Friends SinaWeibo ")) { //获取新浪微博好友,第一页,每页15条数据 print("Click Btn Of Get Friends SinaWeibo"); // ssdk.GetFriendList (PlatformType.SinaWeibo, 15, 0); ssdk.openMiniProgram("gh_afb25ac019c9", "pages/index/index", 0); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Get Token SinaWeibo ")) { Hashtable authInfo = ssdk.GetAuthInfo(PlatformType.SinaWeibo); print("share result :"); print(MiniJSON.jsonEncode(authInfo)); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Close SSO Auth")) { ssdk.DisableSSO(true); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Remove Authorize ")) { ssdk.CancelAuthorize(PlatformType.SinaWeibo); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Add Friend ")) { //关注新浪微博 ssdk.AddFriend(PlatformType.SinaWeibo, "3189087725"); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "ShareWithContentName")) { Hashtable customFields = new Hashtable(); customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; //根据配置文件分享【本接口功能仅暂时支持iOS】 ssdk.ShareWithContentName(PlatformType.SinaWeibo, "ShareSDK", customFields); } btnWidth += 80 * scale; btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "ShowShareMenuWithContentName")) { Hashtable customFields = new Hashtable(); customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; //根据配置文件展示分享菜单分享【本接口功能仅暂时支持iOS】 ssdk.ShowPlatformListWithContentName("ShareSDK", customFields, null, 100, 100); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "ShowShareViewWithContentName")) { Hashtable customFields = new Hashtable(); //根据配置文件展示编辑界面分享【本接口功能仅暂时支持iOS】 customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; ssdk.ShowShareContentEditorWithContentName(PlatformType.SinaWeibo, "ShareSDK", customFields); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "SMS Authorize")) { ssdk.Authorize(PlatformType.SMS); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Share wxMiniProgram (ios only)")) { ShareContent content = new ShareContent(); content.SetTitle("MiniProgram"); content.SetText("test MiniProgram"); content.SetUrl("http://www.mob.com"); content.SetMiniProgramPath("pages/index/index"); content.SetThumbImageUrl( "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1527484508213&di=d993c2ca41fec50717d137718511120f&imgtype=0&src=http%3A%2F%2Fimg5.2345.com%2Fduoteimg%2FzixunImg%2Flocal%2F2017%2F05%2F03%2F14938009295612.jpg"); content.SetMiniProgramHdThumbImage( "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1522154322305&di=7f4bf3d0803fe8c2c66c140f0a6ea0b4&imgtype=0&src=http%3A%2F%2Fa4.topitme.com%2Fo%2F201007%2F29%2F12803876734174.jpg"); content.SetMiniProgramUserName("gh_afb25ac019c9"); content.SetMiniProgramWithShareTicket(true); content.SetMiniProgramType(0); content.SetShareType(ContentType.MiniProgram); ShareContent shareContent = new ShareContent(); shareContent.SetShareContentCustomize(PlatformType.WeChat, content); ssdk.ShareContent(PlatformType.WeChat, shareContent); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Share Sina LinkCard")) { #if UNITY_IPHONE ShareContent content = new ShareContent(); content.SetText("sina LinkCard"); content.SetUrl("http://www.mob.com"); content.SetImageUrl("http://www.mob.com/assets/images/ShareSDK_pic_1-09d293a6.png");//必须为网络图片 content.SetSinaLinkCard(true); content.SetSinaCardTitle("这是Title"); content.SetSinaCardSummary("这是Summary"); content.SetShareType(ContentType.Webpage); ShareContent shareContent = new ShareContent(); shareContent.SetShareContentCustomize(PlatformType.SinaWeibo, content); ssdk.ShareContent(PlatformType.SinaWeibo, shareContent); #elif UNITY_ANDROID JsonData jsonData = new JsonData(); jsonData["url"] = "http://wx4.sinaimg.cn/large/006WfoFPly1fq0jo9svnaj30dw0dwdhv.jpg"; jsonData["width"] = "120"; jsonData["height"] = "120"; ShareContent content = new ShareContent(); content.SetText("sina LinkCard"); content.SetSinaCardCreateAtAndroid("2019-01-24"); content.SetSinaCardDisplayNameAndroid("displayName"); content.SetSinaCardSummary("Summary"); content.SetSinaCardURLAndroid("http://www.mob.com/"); content.SetSinaCardTypeAndroid("webpage"); content.SetSinaCardImageAndroid(jsonData); content.SetEnableClientShare(true); ShareContent shareContent = new ShareContent(); shareContent.SetShareContentCustomize(PlatformType.SinaWeibo, content); ssdk.ShareContent(PlatformType.SinaWeibo, shareContent); #endif } }
/** * 登录,提供给button使用 * */ public void login() { shareSdk.GetUserInfo(PlatformType.WeChat); }
/** * 登录,提供给button使用 * */ public void login() { shareSdk.GetUserInfo(PlatformType.WeChat); //shareSdk.Authorize (PlatformType.WeChat); }
void OnGUI() { GUI.skin = demoSkin; float scale = 1.0f; if (Application.platform == RuntimePlatform.IPhonePlayer) { scale = Screen.width / 320; } float btnWidth = 200 * scale; float btnHeight = 45 * scale; float btnTop = 20 * scale; GUI.skin.button.fontSize = Convert.ToInt32(16 * scale); reqID += 1; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Authorize")) { print(ssdk == null); ssdk.Authorize(reqID, PlatformType.SinaWeibo); } reqID += 1; btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Get User Info")) { ssdk.GetUserInfo(reqID, PlatformType.SinaWeibo); } reqID += 1; btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Show Share Menu")) { Hashtable content = new Hashtable(); content["content"] = "this is a test string."; content["image"] = "https://f1.webshare.mob.com/code/demo/img/1.jpg"; content["title"] = "test title"; content["description"] = "test description"; content["url"] = "http://sharesdk.cn"; //type只对微信分享有效,分享图片Image,分享链接类型为WebPage/News content["type"] = ContentType.Video; content["siteUrl"] = "http://sharesdk.cn"; content["shareTheme"] = "classic"; //ShareTheme has only two value which are skyblue and classic content["site"] = "ShareSDK"; content["musicUrl"] = "http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"; //用sharesdk提供的onekeyshare库,有界面的快捷分享,包括九宫格和skybule风格 #if UNITY_IPHONE //仅支持iOS,定制新浪的分享内容Example,各平台所支持的字段请参考文档 Hashtable sinaContent = new Hashtable(); sinaContent["content"] = "the sina custom content string"; sinaContent["title"] = "the sina title"; //string path = Application.dataPath+"/Raw"+"/ShareSDK.jpg"; string path = "http://img.baidu.com/img/image/zhenrenmeinv0207.jpg"; sinaContent["image"] = path; sinaContent["url"] = "http://sharesdk.cn"; //iOS分享图文类型为Image,分享链接类型为WebPage/News sinaContent["type"] = ContentType.Image; sinaContent["lat"] = "33.33"; sinaContent["lng"] = "99.99"; sinaContent["objID"] = @"sinaID"; content.Add((int)PlatformType.SinaWeibo, sinaContent); #endif ssdk.ShowShareMenu(reqID, null, content, 100, 100); } reqID += 1; btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Show Share View")) { Hashtable content = new Hashtable(); content["content"] = "this is a test string."; content["image"] = "https://f1.webshare.mob.com/code/demo/img/1.jpg"; content["title"] = "test title"; content["description"] = "test description"; content["url"] = "http://sharesdk.cn"; content["type"] = ContentType.News; content["siteUrl"] = "http://sharesdk.cn"; content["shareTheme"] = "classic"; //ShareTheme has only two value which are skyblue and classic content["site"] = "ShareSDK"; content["musicUrl"] = "http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"; //用sharesdk提供的onekeyshare库,有界面的快捷分享,包括九宫格和skybule风格 ssdk.ShowShareView(reqID, PlatformType.TencentWeibo, content); } reqID += 1; btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Share Content")) { Hashtable content = new Hashtable(); content["content"] = "this is a test string."; content["image"] = "https://f1.webshare.mob.com/code/demo/img/1.jpg"; content["title"] = "test title"; content["description"] = "test description"; content["url"] = "http://sharesdk.cn"; content["type"] = ContentType.Image; content["siteUrl"] = "http://sharesdk.cn"; content["site"] = "ShareSDK"; content["musicUrl"] = "http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"; ssdk.ShareContent(reqID, PlatformType.SinaWeibo, content); } reqID += 1; btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Get Friends SinaWeibo ")) { //获取新浪微博好友,第一页,每页15条数据 print("Click Btn Of Get Friends SinaWeibo"); ssdk.GetFriendList(reqID, PlatformType.SinaWeibo, 15, 0); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Get Token SinaWeibo ")) { Hashtable authInfo = ssdk.GetAuthInfo(PlatformType.SinaWeibo); print("share result :"); print(MiniJSON.jsonEncode(authInfo)); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Close SSO Auth")) { ssdk.CloseSSOWhenAuthorize(true); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Remove Authorize ")) { ssdk.CancelAuthorize(PlatformType.SinaWeibo); } reqID += 1; btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Add Friend ")) { //关注新浪微博 ssdk.AddFriend(reqID, PlatformType.SinaWeibo, "3189087725"); } }
} // end Authorize /// <summary> /// 获取用户信息 /// </summary> /// <param name="platform"></param> public void GetUserInfo(PlatformType platform) { ssdk.GetUserInfo(platform); } // end GetUserInfo
public void DoGetUserInfo() { ssdk.GetUserInfo(PlatformType.WeChat); }
//获取用户数据 public void GetUserInfo(PlatformType type) { ssdk.GetUserInfo(type); }