예제 #1
0
    //获取用户信息
    void GetUserInfoResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
    {
        if (state == ResponseState.Success)
        {
            //获取成功的话 可以写一个类放不同平台的结构体,用PlatformType来判断,用户的Json转化成结构体,来做第三方登录。
            switch (type)
            {
            case PlatformType.WeChat:
                Hashtable wxuser = shareSdk.GetAuthInfo(PlatformType.WeChat);
                JsonData  wxjd   = JsonMapper.ToObject(MiniJSON.jsonEncode(wxuser));
                lable.text = "userID:" + wxjd["userID"].ToString();      //Json
                break;

            case PlatformType.QQ:
                Hashtable user = shareSdk.GetAuthInfo(PlatformType.QQ);
                //lable.text = (MiniJSON.jsonEncode(result));  //Json
                JsonData jd = JsonMapper.ToObject(MiniJSON.jsonEncode(user));
                //实例化当前登录的QQ用户信息
                CurrentQQuserInfo = new QQuserInfo(jd["userID"].ToString(), jd["userName"].ToString(), jd["userIcon"].ToString(), jd["token"].ToString());
                lable.text        = "userID:" + CurrentQQuserInfo.userID; //Json
                break;
            }
        }
        else if (state == ResponseState.Fail)
        {
            lable.text = ("fail! error code = " + result["error_code"] + "; error msg = " + result["error_msg"]);
        }
        else if (state == ResponseState.Cancel)
        {
            lable.text = ("cancel !");
        }
    }
예제 #2
0
 void OnGetUserInfoResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
 {
     if (state == ResponseState.Success)
     {
         print("get user info result :");
         print(MiniJSON.jsonEncode(result));
         print("AuthInfo:" + MiniJSON.jsonEncode(ssdk.GetAuthInfo(PlatformType.WeChat)));
         PrintDebugInfo.Add("AuthInfo:" + MiniJSON.jsonEncode(ssdk.GetAuthInfo(PlatformType.WeChat)));
         print("Get userInfo success !Platform :" + type);
     }
     else if (state == ResponseState.Fail)
     {
                     #if UNITY_ANDROID
         print("fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"]);
         PrintDebugInfo.Add("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 !");
         PrintDebugInfo.Add("cancel !");
     }
 }
    private void OnAuthHandler(int reqID, ResponseState state, PlatformType type, Hashtable data)
    {
        Debug.Log("OnAuthHandler state : " + state);
        Debug.Log("OnAuthHandler reqID : " + reqID + " type : " + type);
        Debug.Log("OnAuthHandler data : " + data.toJson());

        if (state == ResponseState.Success)
        {
            if (type == PlatformType.QQ)
            {
                Hashtable datatemp = mShareSDK.GetAuthInfo(type);
                Debug.Log("OnAuthHandler qqdata : " + datatemp.toJson());

                QQData qqdata = JsonUtility.FromJson<QQData>(datatemp.toJson());
                StartCoroutine(QQWebAuth(qqdata));
            }
            else if (type == PlatformType.WeChat)
            {
#if UNITY_ANDROID
                Hashtable datatemp = mShareSDK.GetAuthInfo(type);
                Debug.Log("OnAuthHandler wechatdata : " + datatemp.toJson());

                WechatData wechatdata = JsonUtility.FromJson<WechatData>(datatemp.toJson());
                string token = wechatdata.token;
                string openid = wechatdata.openID;
                string unionid = wechatdata.unionID;
                
                // <<<< clark_add_20190902
                string userId = wechatdata.userID;
                string userName = wechatdata.userName;
                string userIcon = wechatdata.userIcon;
                string userGender = wechatdata.userGender;
                if (userGender == "m")
                    userGender = "Male";
                else
                    userGender = "Female";
                // >>>>
           
                //Debug.Log("OnAuthHandler wechatdata token : " + token + " openid : " + openid + " unionid : " + unionid);

                // <<<< clark_add_20190902
                statusText.GetComponentInChildren<Text>().text = "Login success!!!";
                responseInfo.GetComponentInChildren<Text>().text = " userID : " + userId + "\n\n userName : "******"\n\n Gender : " + userGender + "\n\n PhotoURL : " + userIcon;
                StartCoroutine(setImage(userIcon));
                //responseInfo.GetComponentInChildren<Text>().text = datatemp.toJson();
                // >>>>
#endif

#if UNITY_IPHONE
				PhoneWechatData wechatdata = JsonUtility.FromJson<PhoneWechatData>(data.toJson());
				string token = wechatdata.access_token;
				string openid = wechatdata.openid;
				string unionid = wechatdata.unionid;
				Debug.Log("OnAuthHandler wechatdata token : " + token + " openid : " + openid + " unionid : " + unionid);
#endif
            }
        }
    }
예제 #4
0
    /// <summary>
    /// 获取用户信息回调
    /// </summary>
    /// <param name="reqID"></param>
    /// <param name="state"></param>
    /// <param name="type"></param>
    /// <param name="result"></param>
    void OnGetUserInfoResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
    {
        if (state == ResponseState.Success)
        {
            SQDebug.Log("获取微信信息成功,正在登陆中...");
            print("get user info result :");
            print(MiniJSON.jsonEncode(result));
            print("Get userInfo success ! Platform :" + type);

            //获取用户信息
            print(MiniJSON.jsonEncode(ssdk.GetAuthInfo(PlatformType.WeChat)));
            SQDebug.LogError(MiniJSON.jsonEncode(ssdk.GetAuthInfo(PlatformType.WeChat)));

            Hashtable uuInfo = null;

#if UNITY_ANDROID
            uuInfo = ssdk.GetAuthInfo(PlatformType.WeChat);
#elif UNITY_IPHONE
            uuInfo = result;
#endif
            if (uuInfo.Contains("openID") || uuInfo.Contains("res"))
            {
                Dictionary <string, object> loginData = new Dictionary <string, object>();
                loginData.Add("openId", uuInfo["openID"].ToString());
                loginData.Add("headUrl", uuInfo["userIcon"].ToString());
                loginData.Add("nickName", Helper.Base64Encode(uuInfo["userName"].ToString()));
                loginData.Add("sex", result["sex"]);
                //Global.It.mLoginCtrl.WeChatLogin(loginData);

                SQDebug.LogError("发送登陆指令。。。。。。。");
            }
            else
            {
                SQDebug.LogError("没发送登陆指令。。。。。。。" + uuInfo);
            }
        }
        else if (state == ResponseState.Fail)
        {
            SQDebug.LogError("微信获取信息失败");
#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)
        {
            SQDebug.LogError("微信获取信息失败");
            print("cancel !");
        }
    }
예제 #5
0
    /// <summary>
    /// 获取token信息
    /// </summary>
    void GetAuthInfo(PlatformType type)
    {
        Hashtable authInfo = ssdk.GetAuthInfo(type);

        string authInfoJson = MiniJSON.jsonEncode(authInfo);

        Debug.LogError("授权回调authInfo:" + authInfoJson);


        accessToken = authInfo["token"].ToString();
        openId      = authInfo["openID"].ToString();

        Regist(Source.wechat);
    }
예제 #6
0
 public void OnSinaLoginBtnClick()
 {
     if (ssdk.IsAuthorized(PlatformType.SinaWeibo))
     {
         Utility.WriteFile(Application.persistentDataPath, "AuthInfo.dat", ssdk.GetAuthInfo(PlatformType.SinaWeibo).toJson());
         Utility.MakeToast("微博用户:" + ssdk.GetAuthInfo(PlatformType.SinaWeibo)["userName"] + "登陆成功!");
         ShareSDKManager.Instance.userPlat = PlatformType.SinaWeibo;
         UnityEngine.SceneManagement.SceneManager.LoadScene(2);
     }
     else
     {
         ssdk.Authorize(PlatformType.SinaWeibo);
     }
 }
예제 #7
0
    void OnGetUserInfoResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
    {
        Debug.Log("ShareSDKManager.OnGetUserInfoResultHandler = state" + state);
        if (state == ResponseState.Success)
        {
            print("get user info result :");
            print(MiniJSON.jsonEncode(result));
            print("AuthInfo:" + MiniJSON.jsonEncode(ssdk.GetAuthInfo(PlatformType.QQ)));
            print("Get userInfo success !Platform :" + 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 !");
        }
        if (null != infoCallback)
        {
            infoCallback(type, state, result);
        }
    }
예제 #8
0
    void OnGetUserInfoResultHandler(int reqID, ResponseState state, PlatformType type, System.Collections.Hashtable result)
    {
        if (state == ResponseState.Success)
        {
            Debug.Log("get user info result :");
            Debug.Log(MiniJSON.jsonEncode(result));
            Debug.Log("AuthInfo:" + MiniJSON.jsonEncode(ssdk.GetAuthInfo(PlatformType.WeChat)));
            Debug.Log("Get userInfo success !Platform :" + type);
            OpenID   = result["openid"].ToString();
            NickName = result["nickname"].ToString();
            HeadIMG  = result["headimgurl"].ToString();

            Debug.Log("nimamamade bi" + HeadIMG);
        }
        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 !");
        }
    }
예제 #9
0
    /// <summary>
    /// 获取用户信息回调
    /// </summary>
    /// <param name="reqID"></param>
    /// <param name="state"></param>
    /// <param name="type"></param>
    /// <param name="result"></param>
    void OnGetUserInfoResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
    {
        if (state == ResponseState.Success)
        {
            SQDebug.Log("获取微信信息成功,正在登陆中...");
            print("get user info result :");
            print(MiniJSON.jsonEncode(result));
            print("Get userInfo success ! Platform :" + type);

            //获取用户信息
            SQDebug.Log(type + "用户信息:" + MiniJSON.jsonEncode(ssdk.GetAuthInfo(type)));
            //SQDebug.Log(MiniJSON.jsonEncode(ssdk.GetAuthInfo(type)));

            Hashtable uuInfo = null;

#if UNITY_ANDROID
            uuInfo = ssdk.GetAuthInfo(type);
#elif UNITY_IPHONE
            uuInfo = result;
#endif
            if (uuInfo.Contains("openID") || uuInfo.Contains("res") || uuInfo.Contains("openid"))
            {
                GetLoginData(uuInfo, result, type);
            }
            else
            {
                SQDebug.Log("没发送登陆指令。。。。。。。" + uuInfo);
            }
        }
        else if (state == ResponseState.Fail)
        {
            Global.Inst.GetController <NetLoadingController>().ShowLoading(false);
            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);
            SQDebug.Log("微信获取信息失败");
            print("cancel !");
        }
    }
예제 #10
0
    // Use this for initialization
    void Start()
    {
        ssdk = ShareSDKManager.Instance.ssdk;
        ssdk.showUserHandler += OnGetUserInfoResultHandler;
        Hashtable authInfo = ssdk.GetAuthInfo(PlatformType.SinaWeibo).toJson().hashtableFromJson();

        StartCoroutine(LoadUserIcon(authInfo["userIcon"].ToString()));
        userName.text = authInfo["userName"].ToString();
        userId.text   = "ID:" + authInfo["userID"].ToString();
    }
예제 #11
0
        /// <summary>
        ///  sharesdk登录认证平台后返回的数据
        /// </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)
        {
            if (state == ResponseState.Success)
            {
                GameModel.GetInstance.ShowNetLoading();

                print("authorize success !" + "Platform :" + type);

                Hashtable res = ssdk.GetAuthInfo(type);

                print(MiniJSON.jsonEncode(res));

//				MessageHint.Show (MiniJSON.jsonEncode(res));
//				var openstr =;
                var openid = "null";
                                #if UNITY_ANDROID
                openid = MiniJSON.jsonEncode(res["userID"]);
                                #elif UNITY_IPHONE
                openid = MiniJSON.jsonEncode(res["uid"]);
                                #endif

//				MessageHint.Show (openid);
                var tmpOpenid = openid.Substring(1, openid.Length - 2);

                if (openid != "" && openid != "null")
                {
                    PlayerPrefs.SetString(GameModel.GetInstance.UserId, tmpOpenid);
                }

                var loginController = UIControllerManager.Instance.GetController <Client.UI.UILoginController> ();
                loginController.WeChatLogin(tmpOpenid);
            }
            else if (state == ResponseState.Fail)
            {
                GameModel.GetInstance.HideNetLoading();
                var str = "";
                                #if UNITY_ANDROID
                print("fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"]);
                str = "fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"].ToString();
                                #elif UNITY_IPHONE
                print("fail! error code = " + result["error_code"] + "; error msg = " + result["error_msg"]);
                str = "fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"].ToString();
                                #endif
                MessageHint.Show(MiniJSON.jsonEncode(str));
            }
            else if (state == ResponseState.Cancel)
            {
                GameModel.GetInstance.HideNetLoading();
                print("cancel !");
            }
            else
            {
                GameModel.GetInstance.HideNetLoading();
            }
        }
    private static void OnGetUserInfoResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
    {
        int platformType = ThirdPlatformTool.fromPlatformType(type);

        if (state == ResponseState.Success)
        {
            Debug.Log("get user info result :");
            Debug.Log(MiniJSON.jsonEncode(result));
            Debug.Log("AuthInfo:" + MiniJSON.jsonEncode(_SSDK.GetAuthInfo(type)));
            Debug.Log("Get userInfo success !Platform :" + type);

            string userInfo = MiniJSON.jsonEncode(result);
            string authInfo = MiniJSON.jsonEncode(_SSDK.GetAuthInfo(type));

            if (_AuthorLuaFunc != null)
            {
                _AuthorLuaFunc.Call((int)ThirdResponseState.Sucess, "授权成功", platformType, userInfo, authInfo);
            }
        }
        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);
            }
        }
    }
예제 #13
0
    private void OnAuthHandler(int reqID, ResponseState state, PlatformType type, Hashtable data)
    {
        Debug.Log("OnAuthHandler state : " + state);
        Debug.Log("OnAuthHandler reqID : " + reqID + " type : " + type);
        Debug.Log("OnAuthHandler data : " + data.toJson());

        if (state == ResponseState.Success)
        {
            if (type == PlatformType.QQ)
            {
                Hashtable datatemp = mShareSDK.GetAuthInfo(type);
                Debug.Log("OnAuthHandler qqdata : " + datatemp.toJson());

                QQData qqdata = JsonUtility.FromJson <QQData>(datatemp.toJson());
                StartCoroutine(QQWebAuth(qqdata));
            }
            else if (type == PlatformType.WeChat)
            {
#if UNITY_ANDROID
                Hashtable datatemp = mShareSDK.GetAuthInfo(type);
                Debug.Log("OnAuthHandler wechatdata : " + datatemp.toJson());

                WechatData wechatdata = JsonUtility.FromJson <WechatData>(datatemp.toJson());
                string     token      = wechatdata.token;
                string     openid     = wechatdata.openID;
                string     unionid    = wechatdata.unionID;
                Debug.Log("OnAuthHandler wechatdata token : " + token + " openid : " + openid + " unionid : " + unionid);
#endif

#if UNITY_IPHONE
                PhoneWechatData wechatdata = JsonUtility.FromJson <PhoneWechatData>(data.toJson());
                string          token      = wechatdata.access_token;
                string          openid     = wechatdata.openid;
                string          unionid    = wechatdata.unionid;
                Debug.Log("OnAuthHandler wechatdata token : " + token + " openid : " + openid + " unionid : " + unionid);
#endif
            }
        }
    }
예제 #14
0
    /// <summary>
    /// 授权成功
    /// </summary>
    private void AuthSucess()
    {
        // 获取到授权信息
        Hashtable info = shareSdk.GetAuthInfo(PlatformType.QQ);
        // 解析json
        JsonData data        = JsonMapper.ToObject(MiniJSON.jsonEncode(info));
        string   userID      = data["userID"].ToString();
        string   username    = data["userName"].ToString();
        string   userIconUrl = data["userIcon"].ToString();
        string   token       = data["token"].ToString();

        user = new QQUser(userID, username, userIconUrl, token);
        EventCenter.Broadcast(EventTypes.AuthSuccess, user);
    }
예제 #15
0
 void OnGetUserInfoResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
 {
     if (hGetUserInfoResult != null)
     {
         if (state == ResponseState.Success)
         {
             hGetUserInfoResult.call(state, type, ssdk.GetAuthInfo(type));
         }
         else
         {
             hGetUserInfoResult.call(state, type, result);
         }
     }
 }
예제 #16
0
    //微信成功登陆回调
    void getUserInforCallback(int reqID, ResponseState state, PlatformType type, Hashtable data)
    {
        if (data != null)
        {
            Debug.Log(data.toJson());
            WeChatLoginInfo Wechatloginfo = new WeChatLoginInfo();
            try
            {
                Wechatloginfo.openid     = (string)data["openid"];
                Wechatloginfo.nickname   = (string)data["nickname"];
                Wechatloginfo.headimgurl = (string)data["headimgurl"];
                //Wechatloginfo.unionid = (string)data["unionid"];
                Wechatloginfo.province = (string)data["province"];
                Wechatloginfo.city     = (string)data["city"];
                Wechatloginfo.IP       = Game.SocketHall.getIpAddress(); //获取ip地址
                Debug.Log("Wechatloginfo.openid" + Wechatloginfo.openid + "Wechatloginfo.nickName" + Wechatloginfo.nickname + "city" + Wechatloginfo.city);
                Game.SocketHall.username = (string)data["openid"];       //oppenid
                Hashtable authinfo = shareSdk.GetAuthInfo(PlatformType.WeChat);
                Game.SocketHall.password  = (string)authinfo["token"];   //token
                Game.SocketHall.ip        = Game.SocketHall.getIpAddress();
                Game.SocketHall.loginType = 3;
                //获取ip地址
                print("ranger****username" + username + "password" + password);
                //发送到服务器
                //Game.SocketHall.LoginMsg((string)data["openid"], (string)data["unionid"], loginType);
                //服务器回调

                //跳转界面
                //Game.UIMgr.PushScene(UIPage.MainPage);
                Game.SocketHall.doLogin();
            }
            catch (System.Exception e)
            {
                Debug.Log("微信接口有变动!" + e.Message);
                return;
            }
        }
        else
        {
            Debug.Log("微信date数据为空");
        }
        Debug.Log("微信回调成功");
    }
예제 #17
0
파일: Loding.cs 프로젝트: Fransice/ShareSDK
    /// <summary>
    /// 授权回掉
    /// </summary>
    /// <param name="reqID"></param>
    /// <param name="state"></param>
    /// <param name="type"></param>
    /// <param name="result"></param>
    void AuthResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
    {
        switch (state)
        {
        case ResponseState.Success:
            print("authorize success !");

            //在控制台输出
            myConsole.text += "\n" + "authorize success !";

            Hashtable user = shareSdk.GetAuthInfo(PlatformType.QQ);

            print("get user info result =====================>:");
            print(MiniJSON.jsonEncode(user));

            JsonData jd = JsonMapper.ToObject(MiniJSON.jsonEncode(user));

            //实例化当前登录的QQ用户信息
            CurrentQQuserInfo = new QQuserInfo(jd["userID"].ToString(), jd["userName"].ToString(),
                                               jd["userIcon"].ToString(), jd["token"].ToString());

            //打印用户信息
            print("userID:" + CurrentQQuserInfo.userID + "===" + "userName:"******"===" +
                  "userIcon:" + CurrentQQuserInfo.userIcon + "===" +
                  "token:" + CurrentQQuserInfo.token);


            //在控制台输出
            myConsole.text += "\n" + "userID:" + CurrentQQuserInfo.userID + "===" + "userName:"******"===" + "userIcon:" + CurrentQQuserInfo.userIcon +
                              "===" +
                              "token:" + CurrentQQuserInfo.token;
            break;

        case ResponseState.Fail:
            print("fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"]);
            break;

        case ResponseState.Cancel:
            print("cancel !");
            break;
        }
    }
예제 #18
0
    //void OnConnect()
    //{
    //    Game.SocketHall.SocketNetTools.OnConnect -= OnConnect;

    //    if (Game.SocketHall.SocketNetTools.Connected)
    //    {
    //        Game.SocketHall.LoginMsg(_opendid, _token, 3);
    //    }
    //    else
    //    {
    //        //Game.LoadingPage.Hide();
    //        Game.DialogMgr.PushDialog(UIDialog.SingleBtnDialog, "连接失败!");
    //    }
    //}

    void OnAuthResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
    {
        if (state == ResponseState.Success)
        {
            print("authorize success !" + "Platform :" + type);


            Hashtable authinfo = shareSdk.GetAuthInfo(PlatformType.WeChat);
            print("OnAuthResultHandler-GetAuthInfo" + MiniJSON.jsonEncode(authinfo));

            //         _opendid = (string)authinfo["openID"];
            //          _token = (string)authinfo["token"];


#if UNITY_ANDROID
            _opendid = (string)authinfo["openID"];
            _token   = (string)authinfo["token"];
#elif UNITY_IPHONE
            _opendid = (string)authinfo["uid"];
            _token   = (string)authinfo["token"];
#endif
            print("OnAuthResultHandler-send username and password: "******"  " + _token);

            //  doLogin();

            string loginid = _opendid + "," + _token;
            SceneMain.Instance.OnThirdLogin(loginid);
        }
        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 !");
        }
    }
예제 #19
0
    void OnGetUserInfoResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
    {
        Debug.Log("OnGetUserInfoResultHandler");
        if (state == ResponseState.Success)
        {
            print("get user info result :");
            print(MiniJSON.jsonEncode(result));
            print("AuthInfo:" + MiniJSON.jsonEncode(sdk.GetAuthInfo(PlatformType.WeChat)));
            print("Get userInfo success !Platform :" + type);

            if (getWeChatUserInfo != null)
            {
                LuaTable tab      = AppMng.luaEnv.NewTable();
                string   nickname = result ["nickname"].ToString();
                nickname = new Regex(@"([^\u4e00-\u9fa5a-zA-z0-9\s].*?)").Replace(nickname, " ");
                tab.Set("open_id", result["openid"].ToString());
                tab.Set("user_name", nickname);
                tab.Set("sex", result["sex"].ToString());
                tab.Set("city", result["city"].ToString());
                tab.Set("portrait", result["headimgurl"].ToString());
                tab.Set("user_ip", Network.player.ipAddress);
                getWeChatUserInfo(tab);
            }
        }
        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 !");
        }
    }
예제 #20
0
    void OnGetUserInfoResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
    {
        if (state == ResponseState.Success)
        {
            print("get user info result :");
            print(MiniJSON.jsonEncode(result));
            print("Get userInfo success !Platform :" + type);
            //获取成功的话 可以写一个类放不同平台的结构体,用PlatformType来判断,用户的Json转化成结构体,来做第三方登录。
            switch (type)
            {
            case PlatformType.WeChat:
            {
                Hashtable authInfoResult = ssdk.GetAuthInfo(PlatformType.WeChat);
                print("getUserauthInfo:");
                print(MiniJSON.jsonEncode(authInfoResult));
                string userInfo = MiniJSON.jsonEncode(result);          //Json
                string authInfo = MiniJSON.jsonEncode(authInfoResult);
                //weChatUserInfo info = weChatUserInfo.CreateFromJson(userInfo);
                //print("weixinxinxi:" + info.city + info.province + info.headimgurl + info.unionid + info.openid + info.nickname + info.city);
                LuaFramework.Util.CallMethod("LoginCtrl", "OnWeChatLoginInfoSend", userInfo, authInfo);
            }
            break;
            }
        }
        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 !");
        }
    }
예제 #21
0
    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);
        }
    }
예제 #22
0
    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 btnWidth2 = btnWidth + 80 * scale;

        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);

#if UNITY_ANDROID
            ssdk.Authorize(PlatformType.SinaWeibo);
#elif UNITY_IPHONE
            ssdk.Authorize(PlatformType.Facebook);
#endif
        }

        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Get User Info"))
        {
            //ssdk.GetUserInfo(PlatformType.Douyin);

            print("share result :" + 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.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 - btnWidth2) / 2, btnTop, btnWidth2, 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.Oasis, 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 - btnWidth2) / 2, btnTop, btnWidth2, btnHeight), "Get Token "))
        {
            Hashtable authInfo = ssdk.GetAuthInfo(PlatformType.QQ);
            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 - btnWidth2) / 2, btnTop, btnWidth2, btnHeight), "Remove Authorize "))
        {
            ssdk.CancelAuthorize(PlatformType.QQ);
        }

        //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 - btnWidth2) / 2, btnTop, btnWidth2, btnHeight), "ShareWithContentName(IOS only)"))
        {
            Hashtable customFields = new Hashtable();
            customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg";
            //根据配置文件分享【本接口功能仅暂时支持iOS】
            ssdk.ShareWithContentName(PlatformType.SinaWeibo, "ShareSDK", customFields);
        }

        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnWidth2) / 2, btnTop, btnWidth2, btnHeight), "ShowShareMenuWithContentName(IOS only)"))
        {
            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 - btnWidth2) / 2, btnTop, btnWidth2, btnHeight), "ShowShareViewWithContentName(IOS only)"))
        {
            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 - btnWidth2) / 2, btnTop, btnWidth2, btnHeight), "SMS Authorize"))
        {
            ssdk.Authorize(PlatformType.SMS);
        }

        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnWidth2) / 2, btnTop, btnWidth2, btnHeight), "submitPolicyGrantResult"))
        {
            Debug.Log("ssdk ======> " + ssdk);
            Debug.Log("mobsdk ======> " + mobsdk);

            mobsdk.submitPolicyGrantResult(true);
        }

        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnWidth2) / 2, btnTop, btnWidth2, btnHeight), "getPrivacyPolicy"))
        {
            Debug.Log("ssdk ======> " + ssdk);
            Debug.Log("mobsdk ======> " + mobsdk);
                        #if UNITY_IPHONE
            mobsdk.getPrivacyPolicy(true);
#elif UNITY_ANDROID
            mobsdk.getPrivacyPolicy(true);
            Debug.Log("mobsdk getPrivacyPolicy======> " + mobsdk.getPrivacyPolicy(true));
#endif
        }


        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Share wxMiniProgram"))
        {
#if UNITY_IPHONE
            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);
            // iOS/Android 微信小程序的版本(0-正式,1-开发,2-体验)
            content.SetMiniProgramType(0);
            //content.SetShareType (ContentType.MiniProgram);

            ShareContent shareContent = new ShareContent();
            shareContent.SetShareContentCustomize(PlatformType.WeChat, content);
            ssdk.ShareContent(PlatformType.WeChat, shareContent);
#elif UNITY_ANDROID
            ShareContent content = new ShareContent();
            content.SetTitle("MiniProgram");
            content.SetText("test MiniProgram");
            content.SetUrl("http://www.mob.com");
            content.SetMiniProgramType(0);
            content.SetMiniProgramUserName("gh_52568203455c");
            content.SetImageUrl("http://pic28.photophoto.cn/20130818/0020033143720852_b.jpg");
            content.SetShareType(ContentType.MiniProgram);

            ShareContent shareContent = new ShareContent();
            shareContent.SetShareContentCustomize(PlatformType.WeChat, content);
            ssdk.ShareContent(PlatformType.WeChat, shareContent);
#endif
        }



        //
        if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Share qqMiniProgram(IOS only)"))
        {
#if UNITY_IPHONE
            ShareContent content = new ShareContent();
            content.SetTitle("MiniProgram");
            content.SetText("test MiniProgram");
            content.SetUrl("http://www.mob.com");
            content.SetThumbImageUrl("http://download.sdk.mob.com/web/images/2019/07/30/14/1564468183056/750_750_65.12.png");
            content.SetMiniProgramPath("pages/index/index");
            content.SetMiniProgramHdThumbImage("http://download.sdk.mob.com/web/images/2019/07/30/14/1564468183056/750_750_65.12.png");
            content.SetMiniProgramAppID("1108318575");
            content.SetMiniProgramWebpageUrl("www.qq.com");
            //iOS/Android QQ小程序的类型,默认正式版(3),可选测试版(1)、预览版(4)
            content.SetMiniProgramType(3);
            content.SetShareType(ContentType.MiniProgram);

            ShareContent shareContent = new ShareContent();
            shareContent.SetShareContentCustomize(PlatformType.QQ, content);
            ssdk.ShareContent(PlatformType.QQ, shareContent);
#elif UNITY_ANDROID
            //===============================================================
            //when you test QQ miniprogram, you should use this params
            //At the same time, the package name and signature should
            //correspond to the package name signature of the specific
            //QQ sharing small program applied in the background of tencent
            //===============================================================
            //ShareContent content = new ShareContent();
            //content.SetTitle("MiniProgram");
            //content.SetText("test MiniProgram");
            //content.SetTitleUrl("http://www.mob.com");
            //content.SetImageUrl("http://www.3wyu.com/wp-content/uploads/6e0eaf15gy1fvr5tnm2dfj20f108gtad.jpg");//必须为网络图片
            //content.SetShareType(ContentType.QQ_MINI_PROGRAM);
            //content.SetMiniProgramAppID("1108318575");
            //content.SetMiniProgramPath("page/share/index.html?share_name=QQ%E9%9F%B3%E4%B9%90&share_key=5aIqFGg&from=disk");
            //content.SetQQMiniProgramType("");

            //ShareContent shareContent = new ShareContent();
            //shareContent.SetShareContentCustomize(PlatformType.QQ, content);
            //ssdk.ShareContent(PlatformType.QQ, shareContent);
#endif
        }

        //btnTop += btnHeight + 20 * scale;
        //if (GUI.Button(new Rect((Screen.width - btnWidth2) / 2, btnTop, btnWidth2, 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
        //}
    }
예제 #23
0
파일: Demo.cs 프로젝트: Fransice/ShareSDK
    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
        }
    }
예제 #24
0
    /**
     * 获取微信个人信息成功回调,登录
     *
     */
    public void authResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable data)
    {
        //TipsManagerScript.getInstance ().setTips ("获取个人信息成功");
        debug_Text.text = ("成功回调微信信息,开始登录");
        //TipsManagerScript.getInstance ().setTipsBig (data.toJson());
                #if UNITY_IOS
        shareSdk.GetUserInfo(PlatformType.WeChat);
        return;
                #else
        data = shareSdk.GetAuthInfo(PlatformType.WeChat);
                #endif
        if (data != null)
        {
            LoginVo loginvo = new LoginVo();
            try {
                MyDebug.Log(data.toJson());
                //TipsManagerScript.getInstance ().setTipsBig (data.toJson());

                loginvo.openId   = (string)data ["openid"];
                loginvo.nickName = (string)data ["nickname"];
                loginvo.headIcon = (string)data ["icon"];
                loginvo.unionid  = (string)data ["unionid"];
                loginvo.province = (string)data ["province"];
                loginvo.city     = (string)data ["city"];
                string sex = data ["gender"].ToString();
                loginvo.sex = int.Parse(sex);
                loginvo.IP  = GlobalDataScript.getInstance().getIpAddress();
                String msg = JsonMapper.ToJson(loginvo);

                PlayerPrefs.SetString("loginInfo", msg);

                CustomSocket.getInstance().sendMsg(new LoginRequest(msg));

                /*
                 * GlobalDataScript.loginVo = loginvo;
                 * GlobalDataScript.loginResponseData = new AvatarVO ();
                 * GlobalDataScript.loginResponseData.account = new Account ();
                 * GlobalDataScript.loginResponseData.account.city = loginvo.city;
                 * GlobalDataScript.loginResponseData.account.openid = loginvo.openId;
                 * MyDebug.Log(" loginvo.nickName:"+loginvo.nickName);
                 * GlobalDataScript.loginResponseData.account.nickname = loginvo.nickName;
                 * GlobalDataScript.loginResponseData.account.headicon = loginvo.headIcon;
                 * GlobalDataScript.loginResponseData.account.unionid = loginvo.city;
                 * GlobalDataScript.loginResponseData.account.sex = loginvo.sex;
                 * GlobalDataScript.loginResponseData.IP = loginvo.IP;
                 *
                 * //加载头像
                 * if(GlobalDataScript.loginVo.sex == 2){
                 *      GlobalDataScript.getInstance().headSprite = Resources.Load ("xianlai/public_ui/head_img_female", typeof(Sprite)) as Sprite;
                 * }else {
                 *      GlobalDataScript.getInstance().headSprite = Resources.Load ("xianlai/public_ui/head_img_male", typeof(Sprite)) as Sprite;
                 * }
                 */
            } catch (Exception e) {
                MyDebug.Log("微信接口有变动!" + e.Message);
                TipsManagerScript.getInstance().setTips("微信接口有变动!" + e.Message);
                return;
            }
        }
        else
        {
            TipsManagerScript.getInstance().setTips("微信登录失败");
        }
    }
예제 #25
0
    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");
        }
    }
예제 #26
0
    void OnGetUserInfoResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
    {
        if (state == ResponseState.Success)
        {
            //Debug.Log("get user info result :");
            //Debug.Log(JsonMapper.ToJson(result));
            //Debug.Log("AuthInfo:" + JsonMapper.ToJson(ssdk.GetAuthInfo(type)));
            //Debug.Log("Get userInfo success !Platform :" + type);

            //授权成功
            var    authinfo = ssdk.GetAuthInfo(type);
            string temp     = JsonMapper.ToJson(authinfo);
            Debug.Log("返回信息为   :  " + temp);

            var item = JsonMapper.ToObject(temp);

            UserID = item["userID"].ToString();
            //ExpiresTime = item["expiresTime"].ToString();
            UserName = item["userName"].ToString();
            Token    = item["token"].ToString();
            UserIcon = item["userIcon"].ToString();
            //UserGender = item["userGender"].ToString();
            Debug.Log("UserID  " + UserID + "   昵称   " + UserName + "  头像 " + UserIcon + " 性别" + UserGender + "    Token    " + Token);

            HttpManager.Instance.ThirdPartyLogin(Token, (i =>
            {
                switch (i)
                {
                case 1010:
                    Debug.Log("未绑定手机号");
                    //BinDingPhonePage.SetActive(true);
                    //LUIS.ThirdOpenID = UserID;
                    //LUIS.UserName = UserName;
                    //LUIS.UserIcon = UserIcon;
                    break;

                case 1013:
                    Debug.Log("登录成功");
                    //  ScenesManager.Instance.LoadMainScene();
                    break;

                default:
                    Debug.Log("登录异常");
                    //     LUIS.PopupInfo("Error");
                    break;
                }
            }));
        }
        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 !");
        }
    }
예제 #27
0
    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);

        if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Authorize"))
        {
            print(ssdk == null);

            ssdk.Authorize(PlatformType.SinaWeibo);
        }

        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Get User Info"))
        {
            ssdk.GetUserInfo(PlatformType.SinaWeibo);
        }

        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Show Share Menu"))
        {
            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.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.Image);
            customizeShareParams.SetObjectID("SinaID");
            content.SetShareContentCustomize(PlatformType.SinaWeibo, customizeShareParams);

            ssdk.ShowPlatformList(null, content, 100, 100);
        }

        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Show Share View"))
        {
            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.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.TencentWeibo, content);
        }

        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Share Content"))
        {
            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.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.ShareContent(PlatformType.SinaWeibo, content);
        }

        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(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.DisableSSO(true);
        }

        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Remove Authorize "))
        {
            ssdk.CancelAuthorize(PlatformType.SinaWeibo);
        }

        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Add Friend "))
        {
            //关注新浪微博
            ssdk.AddFriend(PlatformType.SinaWeibo, "3189087725");
        }
    }
예제 #28
0
    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);
        }
    }
예제 #29
0
    void OnGetUserInfoResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
    {
        if (state == ResponseState.Success)
        {
            //Debug.Log("get user info result :");
            //Debug.Log(JsonMapper.ToJson(result));
            //Debug.Log("AuthInfo:" + JsonMapper.ToJson(ssdk.GetAuthInfo(type)));
            //Debug.Log("Get userInfo success !Platform :" + type);

            //授权成功
            var    authinfo = ssdk.GetAuthInfo(type);
            string temp     = JsonMapper.ToJson(authinfo);
            Debug.Log("返回信息为   :  " + temp);

            var item = JsonMapper.ToObject(temp);

            UserID = item["userID"].ToString();

            UserName = item["userName"].ToString();

            UserIcon = item["userIcon"].ToString();

            Debug.Log("UserID  " + UserID + "   昵称   " + UserName + "  头像 " + UserIcon + " 性别" + UserGender + " Token" + thirdToken);

            HttpManager.Instance.ThirdPartyLogin(UserID, (i =>
            {
                switch (i)
                {
                case 1013:
                    Debug.Log("未绑定手机号");
                    GlobalParameter.ThirduserID = UserID;
                    Debug.Log("GlobalParameter.ThirduserID===" + GlobalParameter.ThirduserID);
                    GlobalParameter.UserName = UserName;
                    Debug.Log("GlobalParameter.UserName===" + GlobalParameter.UserName);
                    GlobalParameter.UserIcon = UserIcon;
                    Debug.Log("GlobalParameter.UserIcon===" + GlobalParameter.UserIcon);


                    LoginUIController.Instance.SetNextUIState(LoginUIState.BinDingPhonePanel);
                    Debug.Log("BinDingPhonePanel");
                    break;

                case 1010:
                    Debug.Log("登录成功");
                    LoginUIController.Instance.PopupInfo("Third");

                    break;

                default:
                    Debug.Log("登录异常");
                    LoginUIController.Instance.PopupInfo("Error");
                    break;
                }
            }));
        }
        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 !");
        }
    }