Skip to content

Instantly share code, notes, and snippets.

@komiya-atsushi
Created November 14, 2012 12:57
Show Gist options
  • Save komiya-atsushi/4071950 to your computer and use it in GitHub Desktop.
Save komiya-atsushi/4071950 to your computer and use it in GitHub Desktop.
URLEntityJSONImpl.init() throws JSONException
JSONObject["display_url"] not found.
Relevant discussions can be found on the Internet at:
http://www.google.co.jp/search?q=531a610a or
http://www.google.co.jp/search?q=02749ab7
TwitterException{exceptionCode=[531a610a-02749ab7 592f0a99-37b91020], statusCode=-1, message=null, code=-1, retryAfter=-1, rateLimitStatus=null, version=3.0.0-SNAPSHOT(build: 92708a174b7c103d12f911d331e7e9c23596ecad)}
at twitter4j.internal.json.URLEntityJSONImpl.init(URLEntityJSONImpl.java:70)
at twitter4j.internal.json.URLEntityJSONImpl.<init>(URLEntityJSONImpl.java:43)
at twitter4j.internal.json.StatusJSONImpl.init(StatusJSONImpl.java:164)
at twitter4j.internal.json.StatusJSONImpl.<init>(StatusJSONImpl.java:85)
at twitter4j.internal.json.z_T4JInternalJSONImplFactory.createStatus(z_T4JInternalJSONImplFactory.java:44)
at twitter4j.AbstractStreamImplementation.asStatus(AbstractStreamImplementation.java:280)
at twitter4j.StatusStreamImpl.onStatus(StatusStreamImpl.java:80)
at twitter4j.AbstractStreamImplementation$1.run(AbstractStreamImplementation.java:107)
at twitter4j.internal.async.ExecuteThread.run(DispatcherImpl.java:116)
Caused by: twitter4j.internal.org.json.JSONException: JSONObject["display_url"] not found.
at twitter4j.internal.org.json.JSONObject.get(JSONObject.java:454)
at twitter4j.internal.org.json.JSONObject.getString(JSONObject.java:635)
at twitter4j.internal.json.URLEntityJSONImpl.init(URLEntityJSONImpl.java:68)
... 8 more
twitter4j.internal.org.json.JSONException: JSONObject["display_url"] not found.
at twitter4j.internal.org.json.JSONObject.get(JSONObject.java:454)
at twitter4j.internal.org.json.JSONObject.getString(JSONObject.java:635)
at twitter4j.internal.json.URLEntityJSONImpl.init(URLEntityJSONImpl.java:68)
at twitter4j.internal.json.URLEntityJSONImpl.<init>(URLEntityJSONImpl.java:43)
at twitter4j.internal.json.StatusJSONImpl.init(StatusJSONImpl.java:164)
at twitter4j.internal.json.StatusJSONImpl.<init>(StatusJSONImpl.java:85)
at twitter4j.internal.json.z_T4JInternalJSONImplFactory.createStatus(z_T4JInternalJSONImplFactory.java:44)
at twitter4j.AbstractStreamImplementation.asStatus(AbstractStreamImplementation.java:280)
at twitter4j.StatusStreamImpl.onStatus(StatusStreamImpl.java:80)
at twitter4j.AbstractStreamImplementation$1.run(AbstractStreamImplementation.java:107)
at twitter4j.internal.async.ExecuteThread.run(DispatcherImpl.java:116)
{
"geo": null,
"in_reply_to_screen_name": null,
"favorited": false,
"text": "RT @fxThailandfans: RT @princezephyr: [PRESS PICS] 121114 f(x) - KOR-AUS Football Match Half-time Show http:\/\/t.co\/cbm1aPCU http:\/\/t.co\/ ...",
"possibly_sensitive": false,
"in_reply_to_status_id_str": null,
"created_at": "Wed Nov 14 12:03:02 +0000 2012",
"in_reply_to_user_id_str": null,
"retweet_count": 2,
"coordinates": null,
"source": "<a href=\"http:\/\/blackberry.com\/twitter\" rel=\"nofollow\">Twitter for BlackBerry\u00ae<\/a>",
"entities": {
"hashtags": [
],
"user_mentions": [
{
"indices": [
3,
18
],
"screen_name": "fxThailandfans",
"id_str": "563934022",
"name": "fx_thailand",
"id": 563934022
},
{
"indices": [
23,
36
],
"screen_name": "princezephyr",
"id_str": "251443396",
"name": "princezephyr",
"id": 251443396
}
],
"urls": [
{
"indices": [
103,
123
],
"display_url": "twitpic.com\/bd46lk",
"url": "http:\/\/t.co\/cbm1aPCU",
"expanded_url": "http:\/\/twitpic.com\/bd46lk"
},
{
"indices": [
124,
136
],
"url": "http:\/\/t.co\/",
"expanded_url": null
}
]
},
"place": null,
"retweeted": false,
"truncated": false,
"id_str": "268685470089764864",
"retweeted_status": {
"geo": null,
"in_reply_to_screen_name": null,
"favorited": false,
"text": "RT @princezephyr: [PRESS PICS] 121114 f(x) - KOR-AUS Football Match Half-time Show http:\/\/t.co\/cbm1aPCU http:\/\/t.co\/UW5HBXHn (7)",
"possibly_sensitive": false,
"in_reply_to_status_id_str": null,
"created_at": "Wed Nov 14 11:42:13 +0000 2012",
"in_reply_to_user_id_str": null,
"retweet_count": 2,
"coordinates": null,
"source": "<a href=\"http:\/\/www.tweetdeck.com\" rel=\"nofollow\">TweetDeck<\/a>",
"entities": {
"hashtags": [
],
"user_mentions": [
{
"indices": [
3,
16
],
"screen_name": "princezephyr",
"id_str": "251443396",
"name": "princezephyr",
"id": 251443396
}
],
"urls": [
{
"indices": [
83,
103
],
"display_url": "twitpic.com\/bd46lk",
"url": "http:\/\/t.co\/cbm1aPCU",
"expanded_url": "http:\/\/twitpic.com\/bd46lk"
},
{
"indices": [
104,
124
],
"display_url": "twitpic.com\/bd46tf",
"url": "http:\/\/t.co\/UW5HBXHn",
"expanded_url": "http:\/\/twitpic.com\/bd46tf"
}
]
},
"place": null,
"retweeted": false,
"truncated": false,
"id_str": "268680229562744832",
"contributors": null,
"in_reply_to_user_id": null,
"in_reply_to_status_id": null,
"user": {
"friends_count": 44,
"profile_link_color": "939AED",
"followers_count": 834,
"is_translator": false,
"default_profile": false,
"follow_request_sent": null,
"contributors_enabled": false,
"time_zone": "Bangkok",
"created_at": "Thu Apr 26 18:22:34 +0000 2012",
"profile_background_color": "C0DEED",
"profile_background_tile": true,
"profile_background_image_url_https": "https:\/\/si0.twimg.com\/profile_background_images\/576266919\/0bvixbmvg2lj69ajtg6i.jpeg",
"url": "http:\/\/www.fxthailand.com\/",
"description": "f(x) Thailand Fans Board.\r\n\r\nhttps:\/\/www.facebook.com\/Fxthailandfans",
"profile_sidebar_fill_color": "DDEEF6",
"default_profile_image": false,
"lang": "en",
"favourites_count": 1,
"profile_sidebar_border_color": "C0DEED",
"profile_image_url_https": "https:\/\/si0.twimg.com\/profile_images\/2592067376\/3q4797y4mhfcvh7b7k14_normal.png",
"location": "",
"id_str": "563934022",
"verified": false,
"notifications": null,
"protected": false,
"screen_name": "fxThailandfans",
"following": null,
"geo_enabled": false,
"profile_use_background_image": true,
"profile_image_url": "http:\/\/a0.twimg.com\/profile_images\/2592067376\/3q4797y4mhfcvh7b7k14_normal.png",
"name": "fx_thailand",
"profile_text_color": "333333",
"id": 563934022,
"listed_count": 6,
"statuses_count": 1840,
"profile_background_image_url": "http:\/\/a0.twimg.com\/profile_background_images\/576266919\/0bvixbmvg2lj69ajtg6i.jpeg",
"utc_offset": 25200
},
"id": 2.6868022956274e+17,
"possibly_sensitive_editable": true
},
"contributors": null,
"in_reply_to_user_id": null,
"in_reply_to_status_id": null,
"user": {
"friends_count": 96,
"profile_link_color": "0084B4",
"followers_count": 62,
"is_translator": false,
"default_profile": true,
"follow_request_sent": null,
"contributors_enabled": false,
"time_zone": null,
"created_at": "Tue Jul 17 12:29:08 +0000 2012",
"profile_background_color": "C0DEED",
"profile_background_tile": false,
"profile_background_image_url_https": "https:\/\/si0.twimg.com\/images\/themes\/theme1\/bg.png",
"url": null,
"description": "\u0e2d\u0e31\u0e19\u0e22\u0e2d\u0e07\u0e04\u0e48\u0e30 !! \u0e09\u0e31\u0e19\u0e0b\u0e39\u0e08\u0e35\u0e27\u0e07\u0e21\u0e34\u0e2a\u0e40\u0e2d \u0e09\u0e31\u0e19\u0e23\u0e31\u0e48\u0e27 \u0e19\u0e48\u0e32\u0e23\u0e31\u0e01 \u0e25\u0e2d\u0e07\u0e1f\u0e2d\u0e25\u0e21\u0e32\u0e2a\u0e34\u0e04\u0e48\u0e30\u0e41\u0e25\u0e49\u0e27\u0e04\u0e38\u0e13\u0e08\u0e30\u0e23\u0e39\u0e49 *\u0e22\u0e34\u0e49\u0e21\u0e2a\u0e27\u0e22*",
"profile_sidebar_fill_color": "DDEEF6",
"default_profile_image": false,
"lang": "th",
"favourites_count": 2,
"profile_sidebar_border_color": "C0DEED",
"profile_image_url_https": "https:\/\/si0.twimg.com\/profile_images\/2748527294\/6cd82d00840820ddc2bedffdfb5e15bd_normal.jpeg",
"location": "\u0e43\u0e19\u0e04\u0e48\u0e32\u0e22 JYP \u0e04\u0e48\u0e30",
"id_str": "700968576",
"verified": false,
"notifications": null,
"protected": false,
"screen_name": "suzy12missA",
"following": null,
"geo_enabled": false,
"profile_use_background_image": true,
"profile_image_url": "http:\/\/a0.twimg.com\/profile_images\/2748527294\/6cd82d00840820ddc2bedffdfb5e15bd_normal.jpeg",
"name": "\u0e19\u0e32\u0e07\u0e40\u0e1a!!\u0e0b\u0e39\u0e08\u0e35^^",
"profile_text_color": "333333",
"id": 700968576,
"listed_count": 1,
"statuses_count": 428,
"profile_background_image_url": "http:\/\/a0.twimg.com\/images\/themes\/theme1\/bg.png",
"utc_offset": null
},
"id": 2.6868547008976e+17,
"possibly_sensitive_editable": true
}
/*
* Reproducing code of TFJ-704 ( http://jira.twitter4j.org/browse/TFJ-704 )
*/
import twitter4j.StallWarning;
import twitter4j.Status;
import twitter4j.StatusDeletionNotice;
import twitter4j.StatusListener;
import twitter4j.TwitterStream;
import twitter4j.TwitterStreamFactory;
public class JSONExceptionDemo {
public static class StatusListenerImpl implements StatusListener {
@Override
public void onException(Exception arg0) {
System.out.println("----");
arg0.printStackTrace();
if (arg0.getCause() != null) {
arg0.getCause().printStackTrace();
}
}
@Override
public void onDeletionNotice(StatusDeletionNotice arg0) {
}
@Override
public void onScrubGeo(long arg0, long arg1) {
}
@Override
public void onStallWarning(StallWarning arg0) {
}
@Override
public void onStatus(Status arg0) {
}
@Override
public void onTrackLimitationNotice(int arg0) {
}
}
public static void main(String[] args) {
TwitterStream stream = TwitterStreamFactory.getSingleton();
stream.addListener(new StatusListenerImpl());
stream.sample();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment