Esempio n. 1
0
        private static string RetrieveTweets(string sinceId)
        {
            BasicAuthCredentials credentials = new BasicAuthCredentials
                                                   {
                                                       Username = WebConfigurationManager.AppSettings["ScreenName"],
                                                       Password = WebConfigurationManager.AppSettings["SuperTweetPassword"]
                                                   };
            RestClient client = new RestClient
                                    {
                                        Authority = "http://api.supertweet.net",
                                        VersionPath = "1"
                                    };

            string possibleSinceId = string.IsNullOrWhiteSpace(sinceId) ? "": string.Format("&since_id={0}", sinceId) ;

            RestRequest request = new RestRequest
                                      {
                                          Credentials = credentials,
                                          Path = string.Format("statuses/home_timeline.json?count=200&include_entities=false{0}", possibleSinceId)
                                      };
            RestResponse response = client.Request(request);

            var content = response.Content;
            return content;
        }
Esempio n. 2
0
        public IdenticaClient(string username, string password)
        {
            Statuses = new Statuses(this);
            Account = new Account(this);
            DirectMessages = new DirectMessages(this);
            Favourites = new Favourites(this);
            Block = new Block(this);
            Friendships = new Friendship(this);
            Lists = new List(this);
            Search = new Search(this);
            Users = new Users(this);
            FriendsAndFollowers = new FriendsAndFollowers(this);

            Credentials = new BasicAuthCredentials
            {
                Username = username,
                Password = password
            };

            Client = new RestClient
                         {
                             Authority = "http://identi.ca/api",

                         };            
            
            Authority = "http://identi.ca/api";

            Encode = false;
        }
Esempio n. 3
0
        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            string auth_key = String.Format("full_auth_token {0}", settings["me2day_token"]);
            IWebCredentials credentials = new BasicAuthCredentials
            {
                Username = (string)settings["me2day_userid"],
                Password = auth_key
            };

            RestClient client = new RestClient
            {
                Authority = "http://me2day.net/api/"
            };

            RestRequest request = new RestRequest
            {
                Credentials = credentials,
                Path = String.Format("create_post/{0}.xml?akey=aed420d038f9b1a7fe3b5c0d94df22f5", settings["me2day_userid"])
            };
            request.AddParameter("post[body]", WatermarkTB.Text);
            request.AddParameter("post[tags]", WatermarkTB2.Text);

            if (imgstream != null)
            {
                request.AddFile("attachment", "image.jpg", imgstream, "image/jpeg");
            }

            var callback = new RestCallback(
                (restRequest, restResponse, userState) =>
                {
                    // Callback when signalled
                }
            );

            client.BeginRequest(request, callback);

            MessageBox.Show("Share successfully.", "Thanks", MessageBoxButton.OK);
            this.NavigationService.GoBack();
        }
Esempio n. 4
0
        private void share_Click(object sender, RoutedEventArgs e)
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                MessageBox.Show("This application must require for internet connection. Please check your internet connection status", "Sorry", MessageBoxButton.OK);
                return;
            }
            if (twitter_chk.IsChecked == false && facebook_chk.IsChecked == false && me2day_chk.IsChecked == false)
            {
                MessageBox.Show("Any account hasn't availiable. Please setting your account.", "Sorry", MessageBoxButton.OK);
                return;
            }
            else
            {
                IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
                if (WatermarkTB.Text.Length == 0 || WatermarkTB.Text == emptystr)
                {
                    MessageBox.Show("Please input your minds :)", "Sorry", MessageBoxButton.OK);
                    return;
                }
                share_status = true;
                wait_text.Text = "Share in progress.. Pleas wait";
                share_pg.Visibility = Visibility.Visible;
                tw_chk = false;
                mw_chk = false;
                fw_chk = false;
                share.Visibility = Visibility.Collapsed;

                if (me2day_chk.IsChecked == true)
                {
                    string auth_key = String.Format("full_auth_token {0}", settings["me2day_token"]);
                    IWebCredentials credentials = new BasicAuthCredentials
                    {
                        Username = (string)settings["me2day_userid"],
                        Password = auth_key
                    };

                    RestClient client = new RestClient
                    {
                        Authority = "http://me2day.net/api/"
                    };

                    RestRequest request = new RestRequest
                    {
                        Credentials = credentials,
                        Path = String.Format("create_post/{0}.xml?akey=aed420d038f9b1a7fe3b5c0d94df22f5", settings["me2day_userid"])
                    };
                    request.AddParameter("post[body]", WatermarkTB.Text);

                    if (img_bool)
                    {
                        IsolatedStorageFileStream fileStream2 = myIsolatedStorage.OpenFile("img.jpg", FileMode.Open, FileAccess.Read);
                        request.AddFile("attachment", "image.jpg", fileStream2, "image/jpeg");
                    }

                    var callback = new RestCallback(
                        (restRequest, restResponse, userState) =>
                        {
                            Dispatcher.BeginInvoke(delegate()
                            {
                                mw_chk = true;
                                chk_share();
                            });
                        }
                    );

                    client.BeginRequest(request, callback);

                }

                if (twitter_chk.IsChecked == true)
                {
                    TwitterService service = new TwitterService("g8F2KdKH40gGp9BXemw13Q", "OyFRFsI05agcJtURtLv8lpYbYRwZAIL5gr5xQNPW0Q");
                    service.AuthenticateWith((string)settings["twitter_token"], (string)settings["twitter_tokensecret"]);
                    string tweet = WatermarkTB.Text;
                    if (img_bool == true)
                        tweet += " " + twit_pic;

                    service.SendTweet(tweet,
                        (tweets, response) =>
                        {
                            Dispatcher.BeginInvoke(delegate()
                            {
                                tw_chk = true;
                                chk_share();
                            });
                        });

                }

                if (facebook_chk.IsChecked == true)
                {
                    RestClient client2 = new RestClient
                    {
                        Authority = "https://graph.facebook.com/",
                    };

                    RestRequest request2 = new RestRequest
                    {
                        Path = "/me/feed?message=" + WatermarkTB.Text
                    };
                    if (img_bool)
                    {
                        IsolatedStorageFileStream fileStream2 = myIsolatedStorage.OpenFile("img.jpg", FileMode.Open, FileAccess.Read);

                        request2 = new RestRequest
                        {
                            Path = "/photos?message=" + WatermarkTB.Text
                        };
                        request2.AddFile("photo", "image.jpg", fileStream2);
                    }
                    request2.AddField("access_token", (string)settings["facebook_token"]);
                    var callback = new RestCallback(
                        (restRequest, restResponse, userState) =>
                        {
                            Dispatcher.BeginInvoke(delegate()
                            {
                                fw_chk = true;
                                chk_share();
                            });
                        }
                        );
                    client2.BeginRequest(request2, callback);
                }

            }
        }