コード例 #1
0
        public async Task <BindingStatus> AddBinding(string username, IMessageChannel channel)
        {
            if (string.IsNullOrEmpty((await twitterSession.GetUserProfile(username)).Name))
            {
                return(BindingStatus.Error);
            }
            using (var db = new TwitterContext(dbOptions))
            {
                var twitterBinding = new TwitterBinding
                {
                    TwitterUsername = username.ToLower(),
                    LatestPost      = DateTime.UtcNow,
                };

                if (db.TwitterChannelBindings.Any(b => b.ChannelId == channel.Id && b.TwitterBinding.TwitterUsername == twitterBinding.TwitterUsername))
                {
                    return(BindingStatus.AlreadyExists);
                }

                db.TwitterChannelBindings.Add(new TwitterChannelBinding
                {
                    TwitterBinding = twitterBinding,
                    ChannelId      = channel.Id,
                });

                await db.SaveChangesAsync();

                return(BindingStatus.Added);
            }
        }
コード例 #2
0
    // Checks to see if there is a currently logged in user
    public bool IsLoggedOn()
    {
        bool isLoggedIn = TwitterBinding.isLoggedIn();

        Debug.Log("Twitter is logged in: " + isLoggedIn);
        return(isLoggedIn);
    }
コード例 #3
0
 // Receives tweets from the users home timeline
 public static void getHomeTimeline()
 {
     if (Application.platform == RuntimePlatform.IPhonePlayer)
     {
         TwitterBinding.performRequest("GET", "1.1/statuses/home_timeline.json", null);
     }
 }
コード例 #4
0
    // Posts the status text and an image.  Note that the url will be appended onto the tweet so you don\'t have the full 140 characters
    public static void postStatusUpdate(string status, string pathToImage)
    {
#if UNITY_ANDROID
        TWITTER.postStatusUpdate(status, System.IO.File.ReadAllBytes(pathToImage));
#elif UNITY_IPHONE
        TWITTER.postStatusUpdate(status, pathToImage);
#endif
    }
コード例 #5
0
 // Posts the status text.  Be sure status text is less than 140 characters!
 public void PostUpdate(string status)
 {
     if (status.Length > 140)
     {
         Debug.Log("Error: Update longer than 140 charachters");
         return;
     }
     TwitterBinding.postStatusUpdate(status);
 }
コード例 #6
0
	// Posts the status text. Be sure status text is less than 140 characters!
    public static void postStatusUpdate( string status )
    {
        if( Application.platform == RuntimePlatform.IPhonePlayer )
		{
			var dict = new Dictionary<string,string>();
			dict.Add( "status", status );
			TwitterBinding.performRequest( "POST", "1.1/statuses/update.json", dict );
		}
    }
コード例 #7
0
 public void Login()
 {
     //Debug.Log("[   DEBUG   ] Twitter::Login");
     if (Username == null || Password == null)
     {
         Debug.Log("Twitter::Logon - Username or password are null");
         Debug.Break();
     }
     else
     {
         TwitterBinding.login(Username, Password);
     }
 }
コード例 #8
0
    void OnGUI()
    {
        beginColumn();

        if (GUILayout.Button("Initialize Twitter"))
        {
            TwitterBinding.init("INSERT_YOUR_INFO_HERE", "INSERT_YOUR_INFO_HERE");
        }


        if (GUILayout.Button("Login with Oauth"))
        {
            TwitterBinding.showOauthLoginDialog();
        }


        if (GUILayout.Button("Logout"))
        {
            TwitterBinding.logout();
        }


        if (GUILayout.Button("Is Logged In?"))
        {
            bool isLoggedIn = TwitterBinding.isLoggedIn();
            Debug.Log("Twitter is logged in: " + isLoggedIn);
        }


        if (GUILayout.Button("Logged in Username"))
        {
            string username = TwitterBinding.loggedInUsername();
            Debug.Log("Twitter username: "******"Post Status Update"))
        {
            TwitterBinding.postStatusUpdate("im posting this from Unity: " + Time.deltaTime);
        }


        if (GUILayout.Button("Post Status Update + Image"))
        {
            var pathToImage = Application.persistentDataPath + "/" + FacebookGUIManager.screenshotFilename;
            TwitterBinding.postStatusUpdate("I'm posting this from Unity with a fancy image: " + Time.deltaTime, pathToImage);
        }


        // if we are on iOS 5+ with a Twitter account setup we can use the tweet sheet
        if (canUseTweetSheet)
        {
            if (GUILayout.Button("Show Tweet Sheet"))
            {
                var pathToImage = Application.persistentDataPath + "/" + FacebookGUIManager.screenshotFilename;
                TwitterBinding.showTweetComposer("I'm posting this from Unity with a fancy image: " + Time.deltaTime, pathToImage);
            }
        }


        if (GUILayout.Button("Custom Request"))
        {
            var dict = new Dictionary <string, string>();
            dict.Add("status", "word up with a boogie boogie update");
            TwitterBinding.performRequest("POST", "1.1/statuses/update.json", dict);
        }

        endColumn(false);


        if (bottomRightButton("Sharing..."))
        {
            Application.LoadLevel("SharingTestScene");
        }
    }
コード例 #9
0
 public void ShowOauthLoginDialog()
 {
     TwitterBinding.showOauthLoginDialog();
 }
コード例 #10
0
 public void Initialize()
 {
     TwitterBinding.init(ConsumerKey, ConsumerSecret);
 }
コード例 #11
0
 // Shows the tweet composer with the status message and optional image and link
 public void ShowTweetComposer(string status, string pathToImage, string link)
 {
     TwitterBinding.showTweetComposer(status, pathToImage, link);
 }
コード例 #12
0
 public void ShowTweetComposer(string status)
 {
     TwitterBinding.showTweetComposer(status);
 }
コード例 #13
0
 // Logs out the current user
 public static void logout()
 {
     TWITTER.logout();
 }
コード例 #14
0
 public bool IsTweetSheetSupported()
 {
     return(TwitterBinding.isTweetSheetSupported());
 }
コード例 #15
0
 // Initializes the Twitter plugin and sets up the required oAuth information
 public static void init(string consumerKey, string consumerSecret)
 {
     TWITTER.init(consumerKey, consumerSecret);
 }
コード例 #16
0
    public bool canUseTweetSheet = false;     // requires iOS 5 and a Twitter account setup in Settings.app


    void Start()
    {
        canUseTweetSheet = TwitterBinding.isTweetSheetSupported() && TwitterBinding.canUserTweet();
        Application.CaptureScreenshot(FacebookGUIManager.screenshotFilename);
    }
コード例 #17
0
 // Performs a request for any available Twitter API methods. methodType must be either "get" or "post".  path is the
 // url fragment from the API docs (excluding https://api.twitter.com) and parameters is a dictionary of key/value pairs
 // for the given method.  See Twitter's API docs for all available methods
 public static void performRequest(string methodType, string path, Dictionary <string, string> parameters)
 {
     TWITTER.performRequest(methodType, path, parameters);
 }
コード例 #18
0
 // Checks to see if there is a currently logged in user
 public static bool isLoggedIn()
 {
     return(TWITTER.isLoggedIn());
 }
コード例 #19
0
 // Posts the status text.  Be sure status text is less than 140 characters!
 public static void postStatusUpdate(string status)
 {
     TWITTER.postStatusUpdate(status);
 }
コード例 #20
0
 // Retuns the currently logged in user's username
 public string GetUsername()
 {
     Username = TwitterBinding.loggedInUsername();
     Debug.Log("Twitter username: " + Username);
     return(Username);
 }
コード例 #21
0
 // Checks to see if a user can tweet (are they logged in with a Twitter account)?
 public bool CanUserTweet()
 {
     return(TwitterBinding.canUserTweet());
 }
コード例 #22
0
 // Logs out the current user
 public void Logout()
 {
     Debug.Log("Logging out user: " + Username);
     TwitterBinding.logout();
 }
コード例 #23
0
 // Logs in the user using oAuth which request displaying the login prompt via an in app browser
 public static void showLoginDialog()
 {
     TWITTER.showLoginDialog();
 }
コード例 #24
0
    void OnGUI()
    {
        beginColumn();

        if (GUILayout.Button("Initialize Twitter"))
        {
            // Replace these with your own CONSUMER_KEY and CONSUMER_SECRET!
            TwitterBinding.init("I1hxdhKOrQm6IsR0szOxQ", "lZDRqdzWJq3cATgfXMDjk0kaYajsP9450wKXYXAnpw");
        }


        if (GUILayout.Button("Login with Oauth"))
        {
            TwitterBinding.showLoginDialog();
        }


        if (GUILayout.Button("Logout"))
        {
            TwitterBinding.logout();
        }


        if (GUILayout.Button("Is Logged In?"))
        {
            bool isLoggedIn = TwitterBinding.isLoggedIn();
            Debug.Log("Twitter is logged in: " + isLoggedIn);
        }


        if (GUILayout.Button("Logged in Username"))
        {
            string username = TwitterBinding.loggedInUsername();
            Debug.Log("Twitter username: "******"Post Status Update"))
        {
            TwitterBinding.postStatusUpdate("im posting this from Unity: " + Time.deltaTime);
        }


        if (GUILayout.Button("Post Status Update + Image"))
        {
            var pathToImage = Application.persistentDataPath + "/" + FacebookGUIManager.screenshotFilename;
            if (!File.Exists(pathToImage))
            {
                Debug.LogError("The file " + pathToImage + " does not exist on disk. Aborting attempting to post it.");
                return;
            }

            // posting an image already saved to disk
            TwitterBinding.postStatusUpdate("I'm posting this from Unity with a fancy image: " + Time.deltaTime, pathToImage);


            // posting raw image data
            TwitterBinding.postStatusUpdate("I'm posting a raw image from Unity with a fancy image: " + Time.deltaTime, File.ReadAllBytes(pathToImage));
        }


        // if we are on iOS 5+ with a Twitter account setup we can use the tweet sheet
        if (canUseTweetSheet)
        {
            if (GUILayout.Button("Show Tweet Sheet"))
            {
                var pathToImage = Application.persistentDataPath + "/" + FacebookGUIManager.screenshotFilename;
                TwitterBinding.showTweetComposer("I'm posting this from Unity with a fancy image: " + Time.deltaTime, pathToImage);
            }
        }


        if (GUILayout.Button("Custom Request"))
        {
            var dict = new Dictionary <string, string>();
            dict.Add("count", "2");
            TwitterBinding.performRequest("GET", "1.1/statuses/home_timeline.json", dict);
        }


        if (GUILayout.Button("Get Home Timeline"))
        {
            TwitterBinding.getHomeTimeline();
        }

        endColumn(false);


        if (bottomRightButton("Sharing..."))
        {
            Application.LoadLevel("SharingTestScene");
        }
    }
コード例 #25
0
 // Receives tweets from the users home timeline
 public void GetHomeTimeline()
 {
     TwitterBinding.getHomeTimeline();
 }