Ejemplo n.º 1
0
        IEnumerator Tweet(string message)
        {
            tweet_state = TweetStateCode.Begin;
            int handle = TweetMediaPlugin.tmTweetAsync(m_ctx, message);

            while (enabled)
            {
                TweetMediaPlugin.tmTweetState state = TweetMediaPlugin.tmGetTweetState(m_ctx, handle);
                if (state.code == TweetMediaPlugin.tmEStatusCode.InProgress)
                {
                    yield return(0);
                }
                else
                {
                    if (state.code == TweetMediaPlugin.tmEStatusCode.Succeeded)
                    {
                        tweet_state = TweetStateCode.Succeeded;
                    }
                    else
                    {
                        m_error_message = state.error_message;
                        tweet_state     = TweetStateCode.Failed;
                    }
                    TweetMediaPlugin.tmReleaseTweetCache(m_ctx, handle);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
 void OnEnable()
 {
     if (m_consumerKey == "" || m_consumerSecret == "")
     {
         Debug.LogWarning("TweetMedia: set consumerKey and consumerSecret!");
     }
     m_ctx = TweetMediaPlugin.tmCreateContext();
 }
Ejemplo n.º 3
0
 void OnDisable()
 {
     TweetMediaPlugin.tmDestroyContext(m_ctx);
     m_ctx.Clear();
 }
Ejemplo n.º 4
0
 public void ClearMedia()
 {
     TweetMediaPlugin.tmClearMedia(m_ctx);
 }
Ejemplo n.º 5
0
 public void AddMedia(IntPtr data, int datasize, TweetMediaPlugin.tmEMediaType mtype)
 {
     TweetMediaPlugin.tmAddMedia(m_ctx, data, datasize, mtype);
 }
Ejemplo n.º 6
0
 public void AddMediaFile(string path)
 {
     TweetMediaPlugin.tmAddMediaFile(m_ctx, path);
 }
Ejemplo n.º 7
0
        IEnumerator Authorize()
        {
            bool authorized = false;

            // 保存された token が有効かチェック
            auth_state = AuthStateCode.VerifyCredentialsBegin;
            TweetMediaPlugin.tmLoadCredentials(m_ctx, m_credentialFile.GetPath());
            TweetMediaPlugin.tmVerifyCredentialsAsync(m_ctx);
            while (enabled)
            {
                var state = TweetMediaPlugin.tmGetVerifyCredentialsState(m_ctx);
                if (state.code == TweetMediaPlugin.tmEStatusCode.InProgress)
                {
                    yield return(0);
                }
                else
                {
                    if (state.code == TweetMediaPlugin.tmEStatusCode.Succeeded)
                    {
                        authorized = true;
                        auth_state = AuthStateCode.VerifyCredentialsSucceeded;
                    }
                    else
                    {
                        m_error_message = state.error_message;
                        auth_state      = AuthStateCode.VerifyCredentialsFailed;
                    }
                    break;
                }
            }

            // token が無効な場合認証処理開始
            while (enabled && !authorized)
            {
                // 認証 URL を取得
                auth_state = AuthStateCode.RequestAuthURLBegin;
                TweetMediaPlugin.tmRequestAuthURLAsync(m_ctx, m_consumerKey, m_consumerSecret);
                while (enabled)
                {
                    var state = TweetMediaPlugin.tmGetRequestAuthURLState(m_ctx);
                    if (state.code == TweetMediaPlugin.tmEStatusCode.InProgress)
                    {
                        yield return(0);
                    }
                    else
                    {
                        if (state.code == TweetMediaPlugin.tmEStatusCode.Succeeded)
                        {
                            m_auth_url = state.auth_url;
                            auth_state = AuthStateCode.RequestAuthURLSucceeded;
                        }
                        else
                        {
                            m_error_message = state.error_message;
                            auth_state      = AuthStateCode.RequestAuthURLFailed;
                            // ここで失敗したらほとんど続けようがない (consumer key / secret が無効かネットワーク障害)
                            yield break;
                        }
                        break;
                    }
                }

                // pin の入力を待って送信
                while (enabled && m_pin.Length == 0)
                {
                    yield return(0);
                }

                m_error_message = "";
                auth_state      = AuthStateCode.EnterPINBegin;
                TweetMediaPlugin.tmEnterPinAsync(m_ctx, m_pin);
                m_pin = "";
                while (enabled)
                {
                    var state = TweetMediaPlugin.tmGetEnterPinState(m_ctx);
                    if (state.code == TweetMediaPlugin.tmEStatusCode.InProgress)
                    {
                        yield return(0);
                    }
                    else
                    {
                        if (state.code == TweetMediaPlugin.tmEStatusCode.Succeeded)
                        {
                            authorized = true;
                            TweetMediaPlugin.tmSaveCredentials(m_ctx, m_credentialFile.GetPath());
                            auth_state = AuthStateCode.EnterPINSucceeded;
                        }
                        else
                        {
                            m_error_message = state.error_message;
                            auth_state      = AuthStateCode.EnterPINFailed;
                        }
                        break;
                    }
                }
            }
        }
Ejemplo n.º 8
0
 public void AddMedia(IntPtr data, int datasize, TweetMediaPlugin.tmEMediaType mtype)
 {
     TweetMediaPlugin.tmAddMedia(m_ctx, data, datasize, mtype);
 }