コード例 #1
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
    }
コード例 #2
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);
 }
コード例 #3
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");
        }
    }
コード例 #4
0
 // Posts the status text.  Be sure status text is less than 140 characters!
 public static void postStatusUpdate(string status)
 {
     TWITTER.postStatusUpdate(status);
 }
コード例 #5
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");
        }
    }