protected override void OnResult(string data)
    {
        List<TweetTemplate> loadedTweets =  new List<TweetTemplate>();
        List<object> tweets =  ANMiniJSON.Json.Deserialize(data) as List<object>;
        foreach(object tweet in tweets) {

            Dictionary<string, object> tweetJSON = (tweet as Dictionary<string, object>);

            TweetTemplate tpl =  new TweetTemplate();
            tpl.id 							= tweetJSON["id_str"] as string;
            tpl.created_at 					= tweetJSON["created_at"] as string;
            tpl.text 						= tweetJSON["text"] as string;
            tpl.source 						= tweetJSON["source"] as string;
            tpl.in_reply_to_status_id 		= tweetJSON["in_reply_to_status_id"] as string;
            tpl.in_reply_to_user_id 		= tweetJSON["in_reply_to_user_id"] as string;
            tpl.in_reply_to_screen_name 	= tweetJSON["in_reply_to_screen_name"] as string;
            tpl.geo 						= tweetJSON["geo"] as string;
            tpl.place 						= tweetJSON["place"] as string;
            tpl.lang 						= tweetJSON["lang"] as string;

            tpl.retweet_count 				= System.Convert.ToInt32(tweetJSON["retweet_count"] as string);
            tpl.favorite_count 				= System.Convert.ToInt32(tweetJSON["favorite_count"] as string);

            TwitterUserInfo user =  new TwitterUserInfo(tweetJSON["user"] as IDictionary);
            tpl.user_id = user.id;

            TwitterDataCash.AddTweet(tpl);
            TwitterDataCash.AddUser(user);
            loadedTweets.Add(tpl);
        }

        TW_APIRequstResult result = new TW_APIRequstResult(true, data);
        result.tweets = loadedTweets;
        dispatch(BaseEvent.COMPLETE, result);
    }
Exemple #2
0
 public static void AddUser(TwitterUserInfo u)
 {
     if (!users.ContainsKey(u.id))
     {
         users.Add(u.id, u);
     }
 }
Exemple #3
0
    private void OnUserDataLoaded(string data)
    {
        _userInfo = new TwitterUserInfo(data);

        TWResult res = new TWResult(true, data);

        OnUserDataRequestCompleteAction(res);
    }
Exemple #4
0
    private void OnUserDataLoaded(string data)
    {
        _userInfo = new TwitterUserInfo(data);

        TWResult res = new TWResult(true, data);

        dispatch(TwitterEvents.USER_DATA_LOADED, res);
        OnUserDataRequestCompleteAction(res);
    }
Exemple #5
0
        private string GetTwitterUserInfoPage(TwitterUserInfo user)
        {
            Page     page = new Page();
            HtmlForm form = new HtmlForm();

            form.EnableViewState = false;

            TwitterUserInfoView ctrl = (TwitterUserInfoView)page.LoadControl(PathProvider.GetFileStaticRelativePath("SocialMedia/TwitterUserInfoView.ascx"));

            ctrl.UserInfo = user;
            form.Controls.Add(ctrl);
            page.Controls.Add(form);
            return(RenderPage(page));
        }
    protected override void OnResult(string data)
    {
        List <TweetTemplate> loadedTweets = new List <TweetTemplate>();


        Dictionary <string, object> statuses = ANMiniJSON.Json.Deserialize(data) as Dictionary <string, object>;

        List <object> tweets = statuses["statuses"] as List <object>;

        foreach (object tweet in tweets)
        {
            Dictionary <string, object> tweetJSON = (tweet as Dictionary <string, object>);

            TweetTemplate tpl = new TweetTemplate();
            tpl.id                      = tweetJSON["id_str"] as string;
            tpl.created_at              = tweetJSON["created_at"] as string;
            tpl.text                    = tweetJSON["text"] as string;
            tpl.source                  = tweetJSON["source"] as string;
            tpl.in_reply_to_status_id   = tweetJSON["in_reply_to_status_id"] as string;
            tpl.in_reply_to_user_id     = tweetJSON["in_reply_to_user_id"] as string;
            tpl.in_reply_to_screen_name = tweetJSON["in_reply_to_screen_name"] as string;
            tpl.geo                     = tweetJSON["geo"] as string;
            tpl.place                   = tweetJSON["place"] as string;
            tpl.lang                    = tweetJSON["lang"] as string;


            tpl.retweet_count  = System.Convert.ToInt32(tweetJSON["retweet_count"] as string);
            tpl.favorite_count = System.Convert.ToInt32(tweetJSON["favorite_count"] as string);


            TwitterUserInfo user = new TwitterUserInfo(tweetJSON["user"] as IDictionary);
            tpl.user_id = user.id;



            TwitterDataCash.AddTweet(tpl);
            TwitterDataCash.AddUser(user);
            loadedTweets.Add(tpl);
        }



        TW_APIRequstResult result = new TW_APIRequstResult(true, data);

        result.tweets = loadedTweets;
        dispatch(BaseEvent.COMPLETE, result);
    }
Exemple #7
0
        protected void AssignUsernameAndEmail()
        {
            Page.Validate();
            if (!IsValid)
            {
                return;
            }

            if (Session["TwitterUser"] == null)
            {
                return;
            }

            TwitterUserInfo twitterUser = (TwitterUserInfo)Session["TwitterUser"];

            Session.Remove("TwitterUser");

            if (Request.Form[tbPickUserName.UniqueID] != null && Utils.User.GetUserIdByUserName(tbPickUserName.Text) != 0)
            {
                Response.Write(string.Format("Username {0} already exists, please select another. <a href='twitterlogin.aspx'>Try again</a>.", tbPickUserName.Text));
                Response.End();
                return;
            }

            if (Utils.User.GetUserIdByEmail(tbEmail.Text) != 0)
            {
                Response.Write(string.Format("Email {0} already exists, please select another or use the password recovery form. <a href='twitterlogin.aspx'>Try again</a>.", tbEmail.Text));
                Response.End();
                return;
            }

            string username = (Request.Form[tbPickUserName.UniqueID] != null) ? tbPickUserName.Text : twitterUser.twitterUsername;

            Utils.User.CreateUser(username, tbEmail.Text, CryptoUtils.GenerateRandomNumericCode(), twitterUser.twitterHomepage, twitterUser.twitterBio, false, string.Empty, string.Empty, string.Empty, "", twitterUser.twitterUsername, "");

            int    userId = 0;
            string userName;

            Utils.User.GetUserByTwitterNameId(twitterUser.twitterUsername, out userId, out userName);

            SaveAvatarFromTwitter(userId, twitterUser.twitterImageURL);

            Utils.User.Login(userId, userName);
            Response.Redirect("default.aspx");
        }
	protected override void OnResult(string data) {



		List<TwitterUserInfo> loadedUsers =  new List<TwitterUserInfo>();
		foreach(object user in ANMiniJSON.Json.Deserialize(data) as List<object>) {
			TwitterUserInfo userInfo =  new TwitterUserInfo(user as IDictionary);
			TwitterDataCash.AddUser(userInfo);

			loadedUsers.Add(userInfo);
		}


		TW_APIRequstResult result = new TW_APIRequstResult(true, data);
		result.users = loadedUsers;

		SendCompleteResult(result);

	}
Exemple #9
0
 public string ShowTwitterUserRelationWindow(string userID)
 {
     try
     {
         //Process authorization
         if (!ProcessAuthorization(HttpContext.Current))
         {
             AccessDenied(HttpContext.Current);
             return(null);
         }
         TwitterDataProvider provider = new TwitterDataProvider(TwitterApiHelper.GetTwitterApiInfoForCurrentUser());
         TwitterUserInfo     user     = provider.LoadUserInfo(Convert.ToDecimal(userID));
         return(GetTwitterUserInfoPage(user));
     }
     catch (Exception ex)
     {
         throw ProcessError(ex, "ShowTwitterUserRelationWindow");
     }
 }
Exemple #10
0
    protected override void OnResult(string data)
    {
        List <TwitterUserInfo> loadedUsers = new List <TwitterUserInfo>();

        foreach (object user in ANMiniJSON.Json.Deserialize(data) as List <object> )
        {
            TwitterUserInfo userInfo = new TwitterUserInfo(user as IDictionary);
            TwitterDataCash.AddUser(userInfo);

            loadedUsers.Add(userInfo);
        }


        TW_APIRequstResult result = new TW_APIRequstResult(true, data);

        result.users = loadedUsers;

        SendCompleteResult(result);
    }
	public static void AddUser(TwitterUserInfo u) {
		if(!users.ContainsKey(u.id)) {
			users.Add(u.id, u);
		}
	}
 private void OnUserDataLoaded(string data)
 {
     _userInfo = new TwitterUserInfo(data);
     dispatch(TwitterEvents.USER_DATA_LOADED);
 }
Exemple #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            oAuthTwitter oAuth = new Utils.oAuthTwitter();

            oAuth.ConsumerKey    = Utils.Settings.TwitterConsumerKey;
            oAuth.ConsumerSecret = Utils.Settings.TwitterConsumerSecret;

            if (!IsPostBack)
            {
                if (Request["oauth_token"] == null)
                {
                    //Redirect the user to Twitter for authorization.
                    //Using oauth_callback for local testing.
                    oAuth.CallBackUrl = Request.Url.ToString();
                    try
                    {
                        Response.Redirect(oAuth.AuthorizationLinkGet());
                    }
                    catch
                    {
                        lblError.Visible = true;
                        return;
                    }
                }
                else
                {
                    //Get the access token and secret.
                    try
                    {
                        oAuth.AccessTokenGet(Request["oauth_token"], Request["oauth_verifier"]);
                    }
                    catch
                    {
                        lblError.Visible = true;
                        return;
                    }

                    if (oAuth.TokenSecret.Length > 0)
                    {
                        //We now have the credentials, so make a call to the Twitter API.
                        string url  = "https://api.twitter.com/1.1/account/verify_credentials.json";
                        string json = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, url, String.Empty);

                        var jss  = new JavaScriptSerializer();
                        var data = jss.Deserialize <dynamic>(json);

                        TwitterUserInfo twitterUser = new TwitterUserInfo();
                        twitterUser.twitterUsername = data["screen_name"];
                        twitterUser.twitterHomepage = data["url"];
                        twitterUser.twitterBio      = data["description"];
                        twitterUser.twitterImageURL = data["profile_image_url"];

                        int    userId;
                        string userName;
                        Utils.User.GetUserByTwitterNameId(twitterUser.twitterUsername, out userId, out userName);

                        //existing twitter user
                        if (userId != 0)
                        {
                            Utils.User.Login(userId, userName);
                            Response.Redirect("default.aspx");
                        }
                        else                         //we have to add a new user
                        {
                            lblTwitterName.Text    = twitterUser.twitterUsername;
                            Session["TwitterUser"] = twitterUser;
                            if (Utils.User.GetUserIdByUserName(twitterUser.twitterUsername) != 0)                             //user already exists, lets show "pick username"
                            {
                                trPickUserName.Visible = pPickUserName.Visible = true;
                            }
                        }
                    }
                }
            }
            else if (Request.Form["pickusernamebtn"] != null)            //user picked the username and clicked the btn
            {
                AssignUsernameAndEmail();
            }
        }