当前位置: 首页>>代码示例>>C#>>正文


C# TwitterService.GetUserProfileFor方法代码示例

本文整理汇总了C#中TweetSharp.TwitterService.GetUserProfileFor方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterService.GetUserProfileFor方法的具体用法?C# TwitterService.GetUserProfileFor怎么用?C# TwitterService.GetUserProfileFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TweetSharp.TwitterService的用法示例。


在下文中一共展示了TwitterService.GetUserProfileFor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getUserProfile

        /// <summary>
        /// Retrieves user profile for the given username
        /// </summary>
        /// <param name="userIdOrName"></param>
        /// <returns></returns>
        public string getUserProfile(string userIdOrName)
        {
            try
            {
                TwitterService twitterService = new TwitterService();
                int userId;
                TwitterUser user = null;

                if (Int32.TryParse(userIdOrName, out userId))
                    user = twitterService.GetUserProfileFor(userId);
                else
                    user = twitterService.GetUserProfileFor(userIdOrName);

                return JsonConvert.SerializeObject(user);
            }
            catch
            {
                throw;
            }
        }
开发者ID:smartek,项目名称:POC,代码行数:25,代码来源:TwitterClient.cs

示例2: GetTwitterFollowerCount

        public long GetTwitterFollowerCount(string vendorName)
        {
            long followerCount = 0;
            TwitterClientInfo twitterClientInfo = new TwitterClientInfo();
            twitterClientInfo.ConsumerKey = ConsumerKey; //Read ConsumerKey out of the app.config
            twitterClientInfo.ConsumerSecret = ConsumerSecret; //Read the ConsumerSecret out the app.config

            TwitterService twitterService = new TwitterService(twitterClientInfo);
            if (string.IsNullOrEmpty(AccessToken) || string.IsNullOrEmpty(AccessTokenSecret))
            {
                //Now we need the Token and TokenSecret

                //Firstly we need the RequestToken and the AuthorisationUrl
                OAuthRequestToken requestToken = twitterService.GetRequestToken();
                Uri authUrl = twitterService.GetAuthorizationUri(requestToken);

                //authUrl is just a URL we can open IE and paste it in if we want
                Console.WriteLine("Please Allow This App to send Tweets on your behalf");
                Process.Start(authUrl.ToString()); //Launches a browser that'll go to the AuthUrl.

                //Allow the App
                Console.WriteLine("Enter the PIN from the Browser:");
                string pin = Console.ReadLine();

                OAuthAccessToken accessToken = twitterService.GetAccessToken(requestToken, pin);

                string token = accessToken.Token; //Attach the Debugger and put a break point here
                string tokenSecret = accessToken.TokenSecret; //And another Breakpoint here

                Console.WriteLine("Write Down The AccessToken: " + token);
                Console.WriteLine("Write Down the AccessTokenSecret: " + tokenSecret);

            }

            twitterService.AuthenticateWith(AccessToken, AccessTokenSecret);
            //var status = twitterService.GetRateLimitStatus();
            var user = twitterService.GetUserProfileFor(vendorName);
            if (user != null)
            {
                followerCount = user.FollowersCount;
            }
            return followerCount;
        }
开发者ID:protechdm,项目名称:TMD,代码行数:43,代码来源:Twitter.cs

示例3: ApplicationBarIconButtonCreate_Click

        private void ApplicationBarIconButtonCreate_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(textBoxTwitterId.Text))
            {
                MessageBox.Show("Twitter IDを入力してください");
                return;
            }

            this.progressBar.Visibility = Visibility.Visible;
            this.Focus();
            var s = new TwitterService();
            s.GetUserProfileFor(textBoxTwitterId.Text, (user, resp) =>
            {
                if (resp.InnerException != null)
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        MessageBox.Show("データの取得に失敗しました");
                        this.progressBar.Visibility = Visibility.Collapsed;
                    });
                    return;
                }

                this.Dispatcher.BeginInvoke(() =>
                {
                    var profileUrl = new Uri(user.ProfileImageUrlHttps.Replace("____normal.jpg", "___.jpg"), UriKind.Absolute);
                    var source = new BitmapImage();
                    source.UriSource = profileUrl;
                    this.imageProfile.Source = source;
                    this.textBlockTwitterId.Text = "id:" + user.ScreenName;
                    this.textBlockScreenName.Text = "name: " + user.Name;
                    this.textBlockLocation.Text = "location: " + user.Location;
                    this.progressBar.Visibility = Visibility.Collapsed;
                });
            });
        }
开发者ID:runceel,项目名称:WP7Apps,代码行数:36,代码来源:MainPage.xaml.cs

示例4: Main

        static void Main(string[] args)
        {
            //OAuthInfo myOAuth =  new OAuthInfo();
            //myOAuth.ConsumerKey = "8TmvHbMNWugTpk9lIpbdQ";
            //myOAuth.ConsumerSecret = "AmDxGd29eSUjERuyy20p5bZaFrpLfgYTCP5Qi1K0crw";
            //myOAuth.AccessToken = "21985278-14mhmDF5238JlIeA68ak2MudVhXuHsmkhsNoMTDsp";
            //myOAuth.AccessSecret = "MTpjzzkibGWM6KU8Za2B4WJUieskPEjrAVxBhY2oQ";

            //TinyTwitter TT = new TinyTwitter(new OAuthInfo());

            //IEnumerable<Tweet> mytimneline = TT.GetHomeTimeline(null, 2);
            //Console.ReadKey();

            var service = new TwitterService("tedRo766zL7mr7TKZkOugA", "WREOp5SZ71EtLCt3T4RboUv1IrkUpPkCpcBxkAGk8");
            //var service = new TwitterService("bWDpCLO2mIByqMYoaRh2Cg", "X4veUKVWhB09wipWhVpaVhXvLDHqzIjnOLOGXxiY8Y");
            service.AuthenticateWith("21985278-dud1wSertHCQYTUK5ta5AA0ciqWB31ZsT8Dt8DJg", "yPDp2TTOOhQj6XDxX7P5TxmNtHZcQ6sJumth8DVzRk");
            //service.AuthenticateWith("25963011-QuJkeaEcXqB92bhMxoIJHKBLFHP1rPZysu6K68IqZ", "pY0TXRW8aIUSDfSUpJAzsQ2s2Oay2A0HBdiaK1Z8");
            //var tweets = service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions());
            //var tweets = service.ListRetweetsOfMyTweets(new ListRetweetsOfMyTweetsOptions());
            //var tweets = service.ListFavoriteTweets(new ListFavoriteTweetsOptions());
            var tweets = service.ListTweetsMentioningMe(new ListTweetsMentioningMeOptions());

            //var MyTweetOptions = new SendTweetOptions();
            //MyTweetOptions.Status = "Hello World";

            //service.SendTweet(MyTweetOptions);

            var myFriendLists = service.GetIncomingFriendRequests(new GetIncomingFriendRequestsOptions());

            foreach (var FriendLists in myFriendLists)
            {
                var MyFriendOptions = new GetUserProfileForOptions();
                MyFriendOptions.UserId = FriendLists;

                var MyFriend = service.GetUserProfileFor(MyFriendOptions);

                Console.WriteLine("{0} says", FriendLists.ToString());
                Console.ReadKey();

            }

            //foreach (var tweet in tweets)
            //{
            //    Console.WriteLine("{0} says '{1}'", tweet.Id, tweet.Text);
            //    Console.ReadKey();

            //}

            //using TweetSharp;

            // Pass your credentials to the service
             //           TwitterService service = new TwitterService("bWDpCLO2mIByqMYoaRh2Cg", "X4veUKVWhB09wipWhVpaVhXvLDHqzIjnOLOGXxiY8Y");

            // Step 1 - Retrieve an OAuth Request Token
            //OAuthRequestToken requestToken = service.GetRequestToken();

            // Step 2 - Redirect to the OAuth Authorization URL
            //Uri uri = service.GetAuthorizationUri(requestToken);
            //Process.Start(uri.ToString());

            // Step 3 - Exchange the Request Token for an Access Token
            //string verifier = Console.ReadLine(); // <-- This is input into your application by your user
            //OAuthAccessToken access = service.GetAccessToken(requestToken, verifier);

            // Step 4 - User authenticates using the Access Token
            //service.AuthenticateWith(access.Token, access.TokenSecret);
            //IEnumerable<TwitterStatus> mentions = service.ListTweetsMentioningMe);

            //var tweets = service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions());
            //var myRetweetsOption = new ListRetweetsOfMyTweetsOptions();
            //myRetweetsOption.SinceId = 313064862320300032;
            //tweets = service.ListRetweetsOfMyTweets(myRetweetsOption);
            //
            //foreach (var tweet in tweets)
            //{
            //Console.WriteLine("{0} says '{1}' id:{3} ", tweet.User.ScreenName, tweet.Text, tweet.Id);
              //  Console.WriteLine("{0} says '{1}' ", tweet.Id, tweet.Text);
            //Console.ReadKey();

            //}
            //Console.ReadKey();
        }
开发者ID:imsunil,项目名称:DeCoder,代码行数:82,代码来源:Program.cs

示例5: GetUserIdFromUsername

 public static TwitterUser GetUserIdFromUsername(TwitterService service, string screenname)
 {
     GetUserProfileForOptions options = new GetUserProfileForOptions ();
     options.ScreenName = screenname;
     return service.GetUserProfileFor (options);
 }
开发者ID:MadeInSpengergasse,项目名称:ReplyBot,代码行数:6,代码来源:TwitterHelper.cs


注:本文中的TweetSharp.TwitterService.GetUserProfileFor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。