Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8993753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:15:54+00:00 2026-06-15T23:15:54+00:00

I want to make Twitter Sentiment Analysis Windows Phone Application. the application works by

  • 0

I want to make Twitter Sentiment Analysis Windows Phone Application.

the application works by retrieving all the related tweets based on what query terms that users entered. for example, if I enter “Windows Phone” in input search box, the results will show all the tweet that contains “windows phone” terms.

here’s the code (that I get from Arik Poznanski’s Blog)

    /// <summary>
    /// Searches the specified search text.
    /// </summary>
    /// <param name="searchText">The search text.</param>
    /// <param name="onSearchCompleted">The on search completed.</param>
    /// <param name="onError">The on error.</param>
    public static void Search(string searchText, Action<IEnumerable<Twit>> onSearchCompleted = null, Action<Exception> onError = null, Action onFinally = null)
    {
        WebClient webClient = new WebClient();

        // register on download complete event
        webClient.OpenReadCompleted += delegate(object sender, OpenReadCompletedEventArgs e)
        {
            try
            {
                // report error
                if (e.Error != null)
                {
                    if (onError != null)
                    {
                        onError(e.Error);
                    }
                    return;
                }

                // convert json result to model
                Stream stream = e.Result;
                DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(typeof(TwitterResults));
                TwitterResults twitterResults = (TwitterResults)dataContractJsonSerializer.ReadObject(stream);

                App thisApp = Application.Current as App;
                thisApp.klasifikasi = new Klasifikasi();

                foreach (Twit Tweet in twitterResults.results)
                {
                    try
                    {
                        thisApp.klasifikasi.UploadData(Tweet); //requesting 
                        break;
                    }
                    finally
                    {
                        // notify finally callback
                        if (onFinally != null)
                        {
                            onFinally();
                        }
                    }
                }
                //thisApp.klasifikasi.UploadDatas(twitterResults.results);
                //thisApp.PositiveTweetModel = new PositiveTweetModel("Positive", twitterResults.results);

                // notify completed callback
                if (onSearchCompleted != null)
                {
                    onSearchCompleted(twitterResults.results);

                   /// Divide the list here

                }
            }
            finally
            {
                // notify finally callback
                if (onFinally != null)
                {
                    onFinally();
                }
            }
        };

        string encodedSearchText = HttpUtility.UrlEncode(searchText);
        webClient.OpenReadAsync(new Uri(string.Format(TwitterSearchQuery, encodedSearchText)));
    }

and to call the method

           TwitterService.Search(
            text,
           (items) => { PositiveList.ItemsSource = items; },
           (exception) => { MessageBox.Show(exception.Message); },
           null
           );

to upload POST Data into the API

    public void UploadData(Twit tweetPerSend)
    {
        if (NetworkInterface.GetIsNetworkAvailable())
        {
            chatterbox.Headers[HttpRequestHeader.ContentType] = "application/x-www-                       form-urlencoded";
            chatterbox.Headers["X-Mashape-Authorization"] = "MXBxYmptdjhlbzVnanJnYndicXNpN2NwdWlvMWE1OjA0YTljMWJjMDg4MzVkYWY2YmIzMzczZWFkNDlmYWRkNDYzNGU5NmI=";

            var Uri = new Uri("https://chatterboxco-sentiment-analysis-for-social-media---nokia.p.mashape.com/sentiment/current/classify_text/");

            StringBuilder postData = new StringBuilder();
            postData.AppendFormat("{0}={1}", "lang", HttpUtility.UrlEncode("en"));
            postData.AppendFormat("&{0}={1}", "text", HttpUtility.UrlEncode(tweetPerSend.DecodedText));
            postData.AppendFormat("&{0}={1}", "exclude", HttpUtility.UrlEncode("is")); // disesuaikan 
            postData.AppendFormat("&{0}={1}", "detectlang", HttpUtility.UrlEncode("0"));
            chatterbox.UploadStringAsync(Uri, "POST", postData.ToString());
            chatterbox.UploadStringCompleted += new UploadStringCompletedEventHandler(chatterbox_UploadStringCompleted);

        }
    }


    void chatterbox_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
    {
        var chatterbox = sender as WebClient;
        chatterbox.UploadStringCompleted -= chatterbox_UploadStringCompleted;
        string response = string.Empty;
        if (!e.Cancelled)
        {
            response = HttpUtility.UrlDecode(e.Result);
            nilaiKlasifikasi = ParsingHasil(response);
            MessageBox.Show(nilaiKlasifikasi.ToString()); //just testing
            //textBlock1.Text = response;
        }
    }

    private double ParsingHasil(String response)
    {

        var result = Regex.Match(@response, @"(?<=""value"": )(-?\d+(\.\d+)?)(?=,|$)");
        Debug.WriteLine(result);
        double hasil = Convert.ToDouble(result.ToString());
        //return Convert.ToInt32(result);
        return hasil;

    }

However, there isn’t only 1 tweet to retrieve, there’ll be many tweets, so the main problem is, after I retrieve all the tweet and request the result to the API, I get this error “WebClient does not support concurrent I/O operations”

Does anyone know how to solve this problem?

any help would be appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:15:55+00:00Added an answer on June 15, 2026 at 11:15 pm

    You’ll have to execute UploadStringAsync synchronously one at a time. (i.e. chain execution of the next UploadStringAsync in the UploadStringCompleted handler.

    Or, create a new WebClient for each UploadStringAsync.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have some problem, i want to make my application OAuth with twitter account
I want to use Twitter's Streaming API to collect all of the tweets of
I want to make an application making use of twitter's bootstrap framework. I have
I'm creating a Application with python twitter API. I want to make a lot
I want to make a login to twitter by myself programmatically. Is it possible
I want to make a Follow a button like Twitter Follow in JQuery, Json
I'm using Twitter Bootstrap and I want to make dropdown look like this: and
I want make interactive application where user launches it and can do various task
I am new android app developer i want make app for tablets and phone
I want to make an android app which will update status in twitter. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.