use of weibo4j.org.json.JSONException in project twitter-2-weibo by rjyo.
the class Tag method constructTags.
public static List<Tag> constructTags(Response res) throws WeiboException {
try {
JSONArray list = res.asJSONArray();
int size = list.length();
List<Tag> tags = new ArrayList<Tag>(size);
for (int i = 0; i < size; i++) {
tags.add(new Tag(list.getJSONObject(i)));
}
return tags;
} catch (JSONException jsone) {
throw new WeiboException(jsone);
} catch (WeiboException te) {
throw te;
}
}
use of weibo4j.org.json.JSONException in project twitter-2-weibo by rjyo.
the class Tag method constructTag.
public static List<FavoritesTag> constructTag(Response res) throws WeiboException {
try {
JSONArray list = res.asJSONObject().getJSONArray("tags");
int size = list.length();
List<FavoritesTag> tags = new ArrayList<FavoritesTag>(size);
for (int i = 0; i < size; i++) {
tags.add(new FavoritesTag(list.getJSONObject(i)));
}
return tags;
} catch (JSONException jsone) {
throw new WeiboException(jsone);
} catch (WeiboException te) {
throw te;
}
}
use of weibo4j.org.json.JSONException in project twitter-2-weibo by rjyo.
the class User method constructIds.
public static String[] constructIds(Response res) throws WeiboException {
try {
JSONArray list = res.asJSONObject().getJSONArray("ids");
String temp = list.toString().substring(1, list.toString().length() - 1);
String[] ids = temp.split(",");
return ids;
} catch (JSONException jsone) {
throw new WeiboException(jsone.getMessage() + ":" + jsone.toString(), jsone);
}
}
use of weibo4j.org.json.JSONException in project twitter-2-weibo by rjyo.
the class InitServlet method createJedisPool.
public JedisPool createJedisPool() {
JedisPool jedisPool;
GenericObjectPool.Config config = new GenericObjectPool.Config();
config.testOnBorrow = true;
config.testWhileIdle = true;
config.maxActive = 25;
config.maxIdle = 0;
config.minIdle = 0;
log.debug("Jedis pool created.");
try {
String services = System.getenv("VCAP_SERVICES");
if (services != null) {
JSONObject obj = new JSONObject(services);
obj = obj.getJSONArray("redis-2.2").getJSONObject(0).getJSONObject("credentials");
String hostname = obj.getString("hostname");
int port = obj.getInt("port");
String password = obj.getString("password");
jedisPool = new JedisPool(config, hostname, port, 0, password);
} else {
jedisPool = new JedisPool(config, "localhost");
log.info("Using localhost Redis server");
}
return jedisPool;
} catch (JSONException e) {
log.error("Failed to init", e);
return null;
}
}
use of weibo4j.org.json.JSONException in project twitter-2-weibo by rjyo.
the class Oauth method ts.
/*
* 处理解析后的json解析
*/
public String ts(String json) {
try {
JSONObject jsonObject = new JSONObject(json);
access_token = jsonObject.getString("oauth_token");
user_id = jsonObject.getString("user_id");
} catch (JSONException e) {
e.printStackTrace();
}
return access_token;
}
Aggregations