{"id":1417,"date":"2022-08-30T15:16:21","date_gmt":"2022-08-30T15:16:21","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/16\/fetching-data-from-twitter-api-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:16:21","modified_gmt":"2022-08-30T15:16:21","slug":"fetching-data-from-twitter-api-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/fetching-data-from-twitter-api-collection-of-common-programming-errors\/","title":{"rendered":"fetching data from twitter api-Collection of common programming errors"},"content":{"rendered":"<p>I am trying to fetch a twitter feed. I am using this URL<\/p>\n<pre><code>https:\/\/twitter.com\/status\/user_timeline\/wwwkrcgenkbe.json?count=25&amp;from=wwwkrcgenkbe\n<\/code><\/pre>\n<p>This url gives the following JSON Format<\/p>\n<pre><code>[\n\n    {\n        \"place\": null,\n        \"retweeted\": false,\n        \"in_reply_to_status_id_str\": null,\n        \"in_reply_to_screen_name\": null,\n        \"possibly_sensitive\": false,\n        \"in_reply_to_status_id\": null,\n        \"truncated\": false,\n        \"in_reply_to_user_id_str\": null,\n        \"user\": { . },\n        \"in_reply_to_user_id\": null,\n        \"contributors\": null,\n        \"coordinates\": null,\n        \"retweet_count\": 0,\n        \"favorited\": false,\n        \"created_at\": \"Tue Oct 09 08:54:53 +0000 2012\",\n        \"geo\": null,\n        \"source\": \"Facebook\",\n        \"id_str\": \"255592155345727489\",\n        \"id\": 255592155345727500,\n        \"possibly_sensitive_editable\": true,\n        \"text\": \"Vorige week won Nele Vangeneugden het shirtje dat Jelle Vossen droeg in de Europa League wedstrijd tegen... http:\/\/t.co\/mwxSsBLP\"\n    },\n<\/code><\/pre>\n<p>I am doing it at the following way. First I add this method.<\/p>\n<pre><code> for (NSDictionary *genkInfo in tweets ) {\n            NSLog(@\"Komt in deze methode\");\n            [Twitter twitterWithGenkInfo:genkInfo inManagedObjectContext:document.managedObjectContext];\n            NSLog(@\"tweets: %@\", tweets); \n        }\n<\/code><\/pre>\n<p>And then I store the values in my core data database at this way.<\/p>\n<pre><code>  + (Twitter *)twitterWithGenkInfo:(NSDictionary *)genkInfo\n                inManagedObjectContext:(NSManagedObjectContext *)context\n{\n    NSLog(@\"till here\");\n    Twitter *twitter= nil;\n    NSLog(@\"till here 2\");\n    twitter = [NSEntityDescription insertNewObjectForEntityForName:@\"Twitter\"\n                                               inManagedObjectContext:context];\n    NSLog(@\"tille here3\");\n    twitter.tweet      = [genkInfo objectForKey:TWITTER_TWEET];\n    twitter.date       = [genkInfo objectForKey:TWITTER_DATE];\n     NSLog(@\"till here 4\");\n    NSLog(@\"tweet is: %@\",twitter.tweet);\n    NSLog(@\"date is: %@\",twitter.date);\n\n    return twitter;\n}\n<\/code><\/pre>\n<p>This method is called in my view controller at the following way.<\/p>\n<pre><code>NSArray *tweets         = [GenkData getTweets];\n\n for (NSDictionary *genkInfo in tweets ) {\n                NSLog(@\"Komt in deze methode\");\n                [Twitter twitterWithGenkInfo:genkInfo inManagedObjectContext:document.managedObjectContext];\n            }\n<\/code><\/pre>\n<p>But I am getting always this error.<\/p>\n<pre><code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull objectForKey:]: unrecognized selector sent to instance 0x2751678'\n<\/code><\/pre>\n<p>Can anybody help?<\/p>\n<p>Thanks in advance!<\/p>\n<p>LOG FILE<\/p>\n<pre><code>Log is: (\n        {\n        contributors = \"\";\n        coordinates = \"\";\n        \"created_at\" = \"Tue Oct 09 12:53:08 +0000 2012\";\n        favorited = 0;\n        geo = \"\";\n        id = 255652115341508608;\n        \"id_str\" = 255652115341508608;\n        \"in_reply_to_screen_name\" = \"\";\n        \"in_reply_to_status_id\" = \"\";\n        \"in_reply_to_status_id_str\" = \"\";\n        \"in_reply_to_user_id\" = \"\";\n        \"in_reply_to_user_id_str\" = \"\";\n        place = \"\";\n        \"possibly_sensitive\" = 0;\n        \"possibly_sensitive_editable\" = 1;\n        \"retweet_count\" = 0;\n        retweeted = 0;\n        source = \"Facebook\";\n        text = \"KRC Genk mobile: de Iphone APP (al meer dan 1 mnd beschikbaar) werd reeds 2226 keer gedownload, de Android APP... http:\/\/t.co\/QidTcLJS\";\n        truncated = 0;\n        user =         {\n            \"contributors_enabled\" = 0;\n            \"created_at\" = \"Fri Nov 20 18:57:28 +0000 2009\";\n            \"default_profile\" = 0;\n            \"default_profile_image\" = 0;\n            description = \"The official twitter account from Belgian Soccer team KRC Genk. Belgium champions 2011. Qualified for UEFA Euro League 2012-2013.\";\n            \"favourites_count\" = 1;\n            \"follow_request_sent\" = \"\";\n            \"followers_count\" = 4831;\n            following = \"\";\n            \"friends_count\" = 21;\n            \"geo_enabled\" = 0;\n            id = 91402003;\n            \"id_str\" = 91402003;\n            \"is_translator\" = 0;\n            lang = en;\n            \"listed_count\" = 94;\n            location = \"Genk -  Belgium\";\n            name = \"KRC Genk\";\n            notifications = \"\";\n            \"profile_background_color\" = C0DEED;\n            \"profile_background_image_url\" = \"http:\/\/a0.twimg.com\/profile_background_images\/84123014\/youtubebg.jpg\";\n            \"profile_background_image_url_https\" = \"https:\/\/si0.twimg.com\/profile_background_images\/84123014\/youtubebg.jpg\";\n            \"profile_background_tile\" = 0;\n            \"profile_image_url\" = \"http:\/\/a0.twimg.com\/profile_images\/654317237\/twitter_thumb_normal.jpg\";\n            \"profile_image_url_https\" = \"https:\/\/si0.twimg.com\/profile_images\/654317237\/twitter_thumb_normal.jpg\";\n            \"profile_link_color\" = 0084B4;\n            \"profile_sidebar_border_color\" = C0DEED;\n            \"profile_sidebar_fill_color\" = DDEEF6;\n            \"profile_text_color\" = 333333;\n            \"profile_use_background_image\" = 1;\n            protected = 0;\n            \"screen_name\" = wwwkrcgenkbe;\n            \"statuses_count\" = 4230;\n            \"time_zone\" = \"\";\n            url = \"http:\/\/www.krcgenk.be\";\n            \"utc_offset\" = \"\";\n            verified = 0;\n        };\n    },\n-[__NSCFNumber managedObjectContext]: unrecognized selector sent to instance 0x9331b40\n<\/code><\/pre>\n<ol>\n<li>\n<p>executeGenkFetch seems to be returning you an empty array, or an array of empty dictionaries. As @ilmiacs said, post the output of tweets.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-16 20:49:30. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I am trying to fetch a twitter feed. I am using this URL https:\/\/twitter.com\/status\/user_timeline\/wwwkrcgenkbe.json?count=25&amp;from=wwwkrcgenkbe This url gives the following JSON Format [ { &#8220;place&#8221;: null, &#8220;retweeted&#8221;: false, &#8220;in_reply_to_status_id_str&#8221;: null, &#8220;in_reply_to_screen_name&#8221;: null, &#8220;possibly_sensitive&#8221;: false, &#8220;in_reply_to_status_id&#8221;: null, &#8220;truncated&#8221;: false, &#8220;in_reply_to_user_id_str&#8221;: null, &#8220;user&#8221;: { . }, &#8220;in_reply_to_user_id&#8221;: null, &#8220;contributors&#8221;: null, &#8220;coordinates&#8221;: null, &#8220;retweet_count&#8221;: 0, &#8220;favorited&#8221;: false, &#8220;created_at&#8221;: &#8220;Tue [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1417","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1417","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1417"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1417\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1417"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}