Beispiel #1
0
 public bool likefunction(string id, string userid, string accesstoken)
 {
     oAuthInstagram _api;
     GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"].ToString(), ConfigurationManager.AppSettings["InstagramClientSec"].ToString(), ConfigurationManager.AppSettings["InstagramCallBackURL"].ToString(), "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
     _api = oAuthInstagram.GetInstance(configi);
     LikesController objlikes = new LikesController();
     bool dd = objlikes.PostUserLike(id, userid, accesstoken);
     return dd;
 }
        public string InstagramLikeUnLike(string LikeCount, string IsLike, string FeedId, string InstagramId, string UserId)
        {

            MongoRepository instagramFeedRepo = new MongoRepository("InstagramFeed");
            string str = string.Empty;
            //GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            //oAuthInstagram _api = new oAuthInstagram();
            //_api = oAuthInstagram.GetInstance(configi);
            try
            {
                objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId);

                LikesController objlikes = new LikesController();
                int islike = Convert.ToInt32(IsLike);
                int LikeCounts = Convert.ToInt32(LikeCount);

                if (islike == 0)
                {
                    islike = 1;
                    bool dd = objlikes.PostUserLike(FeedId, objInstagramAccount.AccessToken);
                    LikeCounts++;
                    //objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts);
                    str = "unlike";

                }
                else
                {

                    islike = 0;
                    bool i = objlikes.DeleteLike(FeedId, objInstagramAccount.AccessToken);
                    LikeCounts = LikeCounts - 1;
                    //objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts);
                    str = "like";

                }

                FilterDefinition<BsonDocument> filter = new BsonDocument("FeedId", FeedId);
                var update = Builders<BsonDocument>.Update.Set("IsLike", islike).Set("LikeCount", LikeCounts);
                instagramFeedRepo.Update<Domain.Socioboard.MongoDomain.InstagramFeed>(update, filter);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            return str;
        }
        public string InstagramLikeUnLike(string LikeCount, string IsLike, string FeedId, string InstagramId, string UserId)
        {
            string str = string.Empty;
            GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram _api = new oAuthInstagram();
            _api = oAuthInstagram.GetInstance(configi);
            try
            {
                objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, Guid.Parse(UserId));

                LikesController objlikes = new LikesController();
                int islike = Convert.ToInt32(IsLike);
                int LikeCounts = Convert.ToInt32(LikeCount);

                if (islike == 0)
                {
                    islike = 1;
                    bool dd = objlikes.PostUserLike(FeedId, objInstagramAccount.AccessToken);
                    LikeCounts++;
                    objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts);
                    str = "unlike";

                }
                else
                {

                    islike = 0;
                    bool i = objlikes.DeleteLike(FeedId, objInstagramAccount.AccessToken);
                    LikeCounts = LikeCounts - 1;
                    objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts);
                    str = "like";

                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            return str;
        }
        public string InstagramLikeUnLike(string LikeCount, string IsLike, string FeedId, string InstagramId, string UserId)
        {
            string str = string.Empty;
            try
            {
                objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, Guid.Parse(UserId));

                LikesController objlikes = new LikesController();
                int islike = Convert.ToInt32(IsLike);
                int LikeCounts = Convert.ToInt32(LikeCount);

                if (islike == 0)
                {
                    islike = 1;
                    bool dd = objlikes.PostUserLike(FeedId,objInstagramAccount.AccessToken);
                    LikeCounts++;
                    objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts);
                    str = "unlike";
               
                }
                else {
                    
                    islike = 0;
                    bool i = objlikes.DeleteLike(FeedId, objInstagramAccount.AccessToken);
                    LikeCounts = LikeCounts - 1;                   
                    objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts);
                    str = "like";
                
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);     
            }
            return str;
        }
Beispiel #5
0
        void ProcessRequest()
        {
            Domain.User user = (Domain.User)Session["LoggedUser"];
            if (Request.QueryString["op"] != null)
            {
                if (Request.QueryString["op"] == "bindFeeds")
                {

                    clsFeedsAndMessages clsfeedsandmess = new clsFeedsAndMessages();
                    string network = Request.QueryString["network"];
                        DataSet ds = clsfeedsandmess.bindFeedsIntoDataTable(user, network);
                        if (network == "facebook")
                        {
                            Session["FacebookFeedDataTable"] = ds.Tables[0];
                        }
                        else if (network == "twitter")
                        {
                            Session["TwitterFeedDataTable"] = ds.Tables[0];
                        }
                        else if (network == "linkedin")
                        {
                            Session["LinkedInFeedDataTable"] = ds.Tables[0];
                        }
                        else if (network == "instagram")
                        {
                            Session["InstagramFeedDataTable"] = ds.Tables[0];
                        }
                        string message = this.BindData(ds.Tables[0]);
                        Response.Write(message);

                }
                else if (Request.QueryString["op"] == "bindProfiles")
                {
                    int i = 0;
                    string profiles = string.Empty;
                    profiles += "<ul class=\"options_list\">";
                    string network = Request.QueryString["network"];

                    if (!string.IsNullOrEmpty(network))
                    {

                        /*facebook profiles for feeds tab*/
                        if (network == "facebook")
                        {
                            FacebookAccountRepository facerepo = new FacebookAccountRepository();
                            ArrayList alstfacebookprofiles = facerepo.getAllFacebookAccountsOfUser(user.Id);
                            foreach (FacebookAccount item in alstfacebookprofiles)
                            {
                                profiles += "<li><a id=\"greencheck_" + i + "\" ><span class=\"network_icon\">" +
                                            "<img src=\"../Contents/Images/fb_icon.png\" width=\"17\" height=\"16\" alt=\"\" /></span>" +
                                         "<span id=\"profileusername_" + i + "\" class=\"user_name\">" + item.FbUserName + "</span><input type=\"hidden\" id=\"fbhidden_" + i + "\" value=\"" + item.FbUserId + "\" /> <span id=\"checkid_" + i + "\" class=\"checkbx_green\">" +
                                             "<img id=\"checkimg_" + i + "\" src=\"../Contents/Images/msg/network_click.png\" width=\"17\" height=\"17\" alt=\"\" onclick=\"checkprofile(this.id,'feed','facebook');\" /></span>" +
                                     "</a></li> ";
                                i++;
                            }
                        }
                        else if (network == "twitter")
                        {
                            TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
                            ArrayList asltwitterprofiles = twtaccountrepo.getAllTwitterAccountsOfUser(user.Id);
                            foreach (TwitterAccount item in asltwitterprofiles)
                            {
                                profiles += "<li><a id=\"greencheck_" + i + "\" ><span class=\"network_icon\">" +
                                     "<img src=\"../Contents/Images/msg/network_twt.png\" width=\"17\" height=\"16\" alt=\"\" /></span>" +
                                  "<span id=\"profileusername_" + i + "\" class=\"user_name\">" + item.TwitterScreenName + "</span> <span id=\"checkid_" + i + "\" class=\"checkbx_green\"><input type=\"hidden\" id=\"twthidden_" + i + "\" value=\"" + item.TwitterUserId + "\">" +
                                      "<img id=\"checkimg_" + i + "\" src=\"../Contents/Images/msg/network_click.png\" width=\"17\" height=\"17\" alt=\"\"  onclick=\"checkprofile(this.id,'feed','twitter');\"/></span>" +
                              "</a></li> ";
                                i++;
                            }
                        }
                        else if (network == "linkedin")
                        {
                            LinkedInAccountRepository liRepo = new LinkedInAccountRepository();
                            ArrayList asllinkedinProfiles = liRepo.getAllLinkedinAccountsOfUser(user.Id);
                            foreach (LinkedInAccount item in asllinkedinProfiles)
                            {
                                profiles += "<li><a id=\"greencheck_" + i + "\" ><span class=\"network_icon\">" +
                                     "<img src=\"../Contents/Images/msg/network_linked.png\" width=\"17\" height=\"16\" alt=\"\" /></span>" +
                                  "<span id=\"profileusername_" + i + "\" class=\"user_name\">" + item.LinkedinUserName + "</span> <span id=\"checkid_" + i + "\" class=\"checkbx_green\"><input type=\"hidden\" id=\"twthidden_" + i + "\" value=\"" + item.LinkedinUserId + "\">" +
                                      "<img id=\"checkimg_" + i + "\" src=\"../Contents/Images/msg/network_click.png\" width=\"17\" height=\"17\" alt=\"\"  onclick=\"checkprofile(this.id,'feed','linkedin');\"/></span>" +
                              "</a></li> ";
                                i++;
                            }
                            profiles += "</ul><input type=\"hidden\" id=\"profilecounter\" value=\"" + i + "\">";
                        }
                        else if (network == "instagram")
                        {
                            InstagramAccountRepository InsRepo = new InstagramAccountRepository();
                            ArrayList aslinstagramProfiles = InsRepo.getAllInstagramAccountsOfUser(user.Id);
                            foreach (InstagramAccount item in aslinstagramProfiles)
                            {
                                profiles += "<li><a id=\"greencheck_" + i + "\" ><span class=\"network_icon\">" +
                                     "<img src=\"../Contents/Images/instagram_24X24.png\" width=\"17\" height=\"16\" alt=\"\" /></span>" +
                                  "<span id=\"profileusername_" + i + "\" class=\"user_name\">" + item.InsUserName + "</span> <span id=\"checkid_" + i + "\" class=\"checkbx_green\"><input type=\"hidden\" id=\"twthidden_" + i + "\" value=\"" + item.InstagramId + "\">" +
                                      "<img id=\"checkimg_" + i + "\" src=\"../Contents/Images/msg/network_click.png\" width=\"17\" height=\"17\" alt=\"\"  onclick=\"checkprofile(this.id,'feed','instagram');\"/></span>" +
                              "</a></li> ";
                                i++;
                            }
                            profiles += "</ul><input type=\"hidden\" id=\"profilecounter\" value=\"" + i + "\">";
                        }
                            Response.Write(profiles);
                    }

                }
                else if (Request.QueryString["op"] == "IntagramProfiles")
                {
                    InstagramAccountRepository InsRepo = new InstagramAccountRepository();
                    ArrayList aslinstagramProfiles = InsRepo.getAllInstagramAccountsOfUser(user.Id);
                    string profiles = string.Empty;
                    string mediaId=Request.QueryString["mediaId"].ToString();
                    foreach (InstagramAccount item in aslinstagramProfiles)
                    {
                        profiles += " <img onclick='postLikeRequest("+ mediaId +","+ item.InstagramId +"," + item.AccessToken + ")' id='" + item.InstagramId + "' src='" + item.ProfileUrl + "'/>";
                    }
                    Response.Write(profiles);
                }
                else if (Request.QueryString["op"] == "postLike")
                {
                    LikesController objlikectr = new LikesController();
                    bool postlike= objlikectr.PostUserLike(Request.QueryString["mediaId"], Request.QueryString["InstagramId"], Request.QueryString["access"]);
                    Response.Write(postlike);
                }
                else if (Request.QueryString["op"] == "updatewallposts")
                {

                    //FacebookAccountRepository fbrepo = new FacebookAccountRepository();
                    //ArrayList alstfbaccounts = fbrepo.getAllFacebookAccountsOfUser(user.Id);
                    //foreach (FacebookAccount item in alstfbaccounts)
                    //{
                    //    FacebookClient fb = new FacebookClient(item.AccessToken);
                    //    FacebookHelper fbhelper = new FacebookHelper();
                    //    var feeds = fb.Get("/me/feed");
                    //    var home = fb.Get("me/home");
                    //    var profile = fb.Get("me");

                    //    long friendscount = 0;
                    //    try
                    //    {
                    //        dynamic friedscount = fb.Get("fql", new { q = "SELECT friend_count FROM user WHERE uid=me()" });
                    //        foreach (var friend in friedscount.data)
                    //        {
                    //            friendscount = friend.friend_count;
                    //        }
                    //    }
                    //    catch (Exception ex)
                    //    {
                    //        Console.WriteLine(ex.StackTrace);
                    //    }
                    //    fbhelper.getFacebookUserHome(home, profile);

                    //    fbhelper.getFacebookUserFeeds(feeds, profile);
                    //    fbhelper.getFacebookUserProfile(profile, item.AccessToken, friendscount, user.Id);
                    //}

                    //clsFeedsAndMessages clsfeedsandmess = new clsFeedsAndMessages();
                    //DataSet ds = clsfeedsandmess.bindFeedsIntoDataTable(user);
                    //string message = this.BindData(ds.Tables[0]);
                    //Response.Write(message);

                }
            }
        }