Пример #1
0
        public static string TwitterUserFollow(string profileId, string toTwitterUserId, Model.DatabaseRepository dbr, ILogger _logger, Helper.Cache _redisCache, Helper.AppSettings _appSettings)
        {
            Domain.Socioboard.Models.TwitterAccount twtacc   = new Domain.Socioboard.Models.TwitterAccount();
            Domain.Socioboard.Models.TwitterAccount imtwtacc = _redisCache.Get <Domain.Socioboard.Models.TwitterAccount>(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterAccount + profileId);
            if (imtwtacc == null)
            {
                twtacc = dbr.Find <Domain.Socioboard.Models.TwitterAccount>(t => t.twitterUserId.Equals(profileId)).FirstOrDefault();
                if (twtacc != null)
                {
                    _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterAccount + profileId, twtacc);
                }
            }
            else
            {
                twtacc = imtwtacc;
            }
            oAuthTwitter oAuth = new oAuthTwitter(_appSettings.twitterConsumerKey, _appSettings.twitterConsumerScreatKey, _appSettings.twitterRedirectionUrl);

            oAuth.AccessToken       = twtacc.oAuthToken;
            oAuth.AccessTokenSecret = twtacc.oAuthSecret;
            oAuth.TwitterScreenName = twtacc.twitterScreenName;
            oAuth.TwitterUserId     = twtacc.twitterUserId;
            FollowerManage follow_obj = new FollowerManage();

            try
            {
                string followUserResp = follow_obj.FollowUserByUserId(oAuth, toTwitterUserId);
                if (followUserResp != "")
                {
                    return("User followed successfully");
                }
                else
                {
                    return("Issue in user following");
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("user following" + ex.StackTrace);
                _logger.LogError("user following" + ex.Message);
                return("api issue while user following");
            }
        }
Пример #2
0
        public static Domain.Socioboard.Models.TwitterFriendRelation TwitterFrindsRelation(string profileId, string toTwitterUserId, Model.DatabaseRepository dbr, ILogger _logger, Helper.Cache _redisCache, Helper.AppSettings _appSettings)
        {
            Domain.Socioboard.Models.TwitterAccount twtacc   = new Domain.Socioboard.Models.TwitterAccount();
            Domain.Socioboard.Models.TwitterAccount imtwtacc = _redisCache.Get <Domain.Socioboard.Models.TwitterAccount>(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterAccount + profileId);
            if (imtwtacc == null)
            {
                twtacc = dbr.Find <Domain.Socioboard.Models.TwitterAccount>(t => t.twitterUserId.Equals(profileId)).FirstOrDefault();
                if (twtacc != null)
                {
                    _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterAccount + profileId, twtacc);
                }
            }
            else
            {
                twtacc = imtwtacc;
            }
            oAuthTwitter oAuth = new oAuthTwitter(_appSettings.twitterConsumerKey, _appSettings.twitterConsumerScreatKey, _appSettings.twitterRedirectionUrl);

            oAuth.AccessToken       = twtacc.oAuthToken;
            oAuth.AccessTokenSecret = twtacc.oAuthSecret;
            oAuth.TwitterScreenName = twtacc.twitterScreenName;
            oAuth.TwitterUserId     = twtacc.twitterUserId;
            FollowerManage follow_obj = new FollowerManage();

            try
            {
                Domain.Socioboard.Models.TwitterFriendRelation _objLstData = new Domain.Socioboard.Models.TwitterFriendRelation();
                string  friendRelationResp  = follow_obj.RelatnFriendshipByUserId(oAuth, toTwitterUserId);
                JObject jFriendRelationResp = JObject.Parse(friendRelationResp);
                if (friendRelationResp == "")
                {
                    return(null);
                }
                else
                {
                    _objLstData.myId                    = jFriendRelationResp["relationship"]["source"]["id_str"].ToString();
                    _objLstData.myScreenName            = jFriendRelationResp["relationship"]["source"]["screen_name"].ToString();
                    _objLstData.myFollowing             = jFriendRelationResp["relationship"]["source"]["following"].ToString();
                    _objLstData.myFollowedBy            = jFriendRelationResp["relationship"]["source"]["followed_by"].ToString();
                    _objLstData.myLiveFollowing         = jFriendRelationResp["relationship"]["source"]["live_following"].ToString();
                    _objLstData.myFollowingReceived     = jFriendRelationResp["relationship"]["source"]["following_received"].ToString();
                    _objLstData.myFollowingRequested    = jFriendRelationResp["relationship"]["source"]["following_requested"].ToString();
                    _objLstData.myNotificationsEnabled  = jFriendRelationResp["relationship"]["source"]["notifications_enabled"].ToString();
                    _objLstData.myCanDm                 = jFriendRelationResp["relationship"]["source"]["can_dm"].ToString();
                    _objLstData.myBlocking              = jFriendRelationResp["relationship"]["source"]["blocking"].ToString();
                    _objLstData.myBlockedBy             = jFriendRelationResp["relationship"]["source"]["blocked_by"].ToString();
                    _objLstData.myMuting                = jFriendRelationResp["relationship"]["source"]["muting"].ToString();
                    _objLstData.myWantRetweets          = jFriendRelationResp["relationship"]["source"]["want_retweets"].ToString();
                    _objLstData.myAllReplies            = jFriendRelationResp["relationship"]["source"]["all_replies"].ToString();
                    _objLstData.myMarkedSpam            = jFriendRelationResp["relationship"]["source"]["marked_spam"].ToString();
                    _objLstData.targetId                = jFriendRelationResp["relationship"]["target"]["id_str"].ToString();
                    _objLstData.targetScreenName        = jFriendRelationResp["relationship"]["target"]["screen_name"].ToString();
                    _objLstData.targetFollowing         = jFriendRelationResp["relationship"]["target"]["following"].ToString();
                    _objLstData.targetFollowedBy        = jFriendRelationResp["relationship"]["target"]["followed_by"].ToString();
                    _objLstData.targetFollowingReceived = jFriendRelationResp["relationship"]["target"]["following_received"].ToString();
                    _objLstData.targetFollowingRequsted = jFriendRelationResp["relationship"]["target"]["following_requested"].ToString();
                    return(_objLstData);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("error finding friendship relation" + ex.StackTrace);
                _logger.LogError("error finding friendship relation" + ex.Message);
                return(null);
            }
        }