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 7949835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:05:24+00:00 2026-06-04T02:05:24+00:00

I have the method below to parse data from the twitter search, strange thing

  • 0

I have the method below to parse data from the twitter search, strange thing is this method works fine in one of my forms but in my main form it returns the exception:

Exception: “System.Collections.Generic.Dictonary” does not
contain a definition for “text”

The two forms are almost identical and i cannot understand why i cant get the code to work.. anyone got any ideas?

Below is the method:

public static HashSet<string> searchTwitterJson(string searchTerm)
    {
        HashSet<string> resultsFound = new HashSet<string>();


        if (searchTerm != "")
        {
            string v = searchTerm.Replace("\"", "%22");
            string keyword = v.Trim();
            string keywordet = HttpUtility.UrlEncode(keyword);


            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://twitter.com/phoenix_search.phoenix?q=" + keywordet + "&headers[X-Twitter-Polling]=true&headers[X-PHX]=true&since_id=203194965877194752&include_entities=1&include_available_features=1&contributor_details=true&mode=relevance&query_source=unknown");
                var response = request.GetResponse();
                var reader = new StreamReader(response.GetResponseStream());
                var responseString = reader.ReadToEnd();

                string limit = response.Headers["X-RateLimit-Remaining"];


                var serializer = new JavaScriptSerializer();
                serializer.RegisterConverters((new[] { new DynamicJsonConverter() }));
                dynamic obj = serializer.Deserialize(responseString, typeof(object)) as dynamic;

                foreach (var objects in obj.statuses) 
                {
                    if ((objects.text != null) && (objects.user.screen_name != null) && (objects.id_str != null))
                    {
                        Match m = Regex.Match(objects.text, @"(http(s)?://)?([\w-]+\.)+[\w-]+(/\S\w[\w- ;,./?%&=]\S*)?");


                        if (!m.Success)
                        {
                            string loggaD = objects.user.screen_name.ToString() + "/" + objects.id_str.ToString();
                            resultsFound.Add(loggaD);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        else
        {
            MessageBox.Show("No searchterm");
        }

        return resultsFound;
    }

Part of the JSON i am receiving:

{
    "error": null,
    "statuses": [{
        "in_reply_to_status_id_str": null,
        "id_str": "203239104421445632",
        "truncated": false,
        "possibly_sensitive": false,
        "created_at": "Thu May 17 21:42:33 +0000 2012",
        "in_reply_to_user_id_str": null,
        "contributors": null,
        "favorited": false,
        "geo": null,
        "user": {
            "screen_name": "YouthNorrort"
        },
        "in_reply_to_screen_name": null,
        "coordinates": null,
        "retweet_count": 0,
        "source": "\u003Ca href=\"http:\/\/www.facebook.com\/twitter\" rel=\"nofollow\"\u003EFacebook\u003C\/a\u003E",
        "place": null,
        "in_reply_to_status_id": null,
        "id": 203239104421445632,
        "retweeted": false,
        "in_reply_to_user_id": null,
        "text": "Hejsan igen!\nvi \u00e4r ledsna att meddela er, men inf\u00f6r imorgon s\u00e5 finns det inga bilar, allts\u00e5 inte heller plats f\u00f6r... http:\/\/t.co\/pMKoOz7o",
        "result_category": "recent"
    }
  • 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-04T02:05:25+00:00Added an answer on June 4, 2026 at 2:05 am

    The error says that the response doesn’t contain an item at the node under “statuses”.[i]. Check the JSON which is being returned, and if it doesn’t have it, then you can’t try to access it.

    {
        "statuses":
        [
            {
                "text": ...,
                "user: { "screen_name": ... }
            }
        ]
    }
    

    The code:

     if ((objects.text != null) && (objects.user.screen_name != null) && (objects.id_str != null))
    

    Update: based on your JSON example, it works fine (see below). Do all elements in the statuses array contain the “text” member?

        public static void Test()
        {
            string json = @"{
    ""error"": null,
    ""statuses"": [{
        ""in_reply_to_status_id_str"": null,
        ""id_str"": ""203239104421445632"",
        ""truncated"": false,
        ""possibly_sensitive"": false,
        ""created_at"": ""Thu May 17 21:42:33 +0000 2012"",
        ""in_reply_to_user_id_str"": null,
        ""contributors"": null,
        ""favorited"": false,
        ""geo"": null,
        ""user"": {
            ""screen_name"": ""YouthNorrort""
        },
        ""in_reply_to_screen_name"": null,
        ""coordinates"": null,
        ""retweet_count"": 0,
        ""source"": ""\u003Ca href=\""http:\/\/www.facebook.com\/twitter\"" rel=\""nofollow\""\u003EFacebook\u003C\/a\u003E"",
        ""place"": null,
        ""in_reply_to_status_id"": null,
        ""id"": 203239104421445632,
        ""retweeted"": false,
        ""in_reply_to_user_id"": null,
        ""text"": ""Hejsan igen!\nvi \u00e4r ledsna att meddela er, men inf\u00f6r imorgon s\u00e5 finns det inga bilar, allts\u00e5 inte heller plats f\u00f6r... http:\/\/t.co\/pMKoOz7o"",
        ""result_category"": ""recent""
    }]}";
            JavaScriptSerializer jss = new JavaScriptSerializer();
            jss.RegisterConverters(new[] { new DynamicJsonConverter() });
            dynamic obj = jss.Deserialize(json, typeof(object)) as dynamic;
    
            foreach (var objects in obj.statuses)
            {
                Console.WriteLine(objects.GetType());
                if (objects.ContainsKey("text"))
                {
                    if ((objects.text != null) && (objects.user.screen_name != null) && (objects.id_str != null))
                    {
                        Match m = Regex.Match(objects.text, @"(http(s)?://)?([\w-]+\.)+[\w-]+(/\S\w[\w- ;,./?%&=]\S*)?");
    
                        if (!m.Success)
                        {
                            string loggaD = objects.user.screen_name.ToString() + "/" + objects.id_str.ToString();
                            Console.WriteLine(loggaD);
                        }
                    }
                }
            }
    

    And the code for TryInvokeMember:

                public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
                {
                    if (binder.Name == "ContainsKey")
                    {
                        result = _dictionary.ContainsKey(args[0] as string);
                        return true;
                    }
                    else
                    {
                        return base.TryInvokeMember(binder, args, out result);
                    }
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have this method below which should insert values into my database. However
I have a doubt regarding downloading data from a web service. One way is
I have the method below, which in my Blackjack app will get the value
I have a method below doing casting on a String according to the given
I have the below method which is meant to append information to a file
I have the below method: public String tryGoogleAuthentication(String auth_token){ ContactsService contactsService = new ContactsService(.....);
I have problem with android 4.0.3. I'm using the method below to get local
I have a generic method define as below public T MyMethod<T>(extra params) My method
I have a method to Generate Expression By Clause as below: internal static Expression<Func<TModel,
I have the classes below: SuppliersRepository.cs (with the interface defining the method): public class

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.