Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ jtwitter.jar
boblog
bin
doc
/.settings
/binlocal
70 changes: 22 additions & 48 deletions src/winterwell/jtwitter/Twitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ public Twitter_Analytics analytics() {
* @param vars
* @return vars
*/
private Map<String, String> addStandardishParameters(
Map<String, String> addStandardishParameters(
Map<String, String> vars) {
if (sinceId != null) {
vars.put("since_id", sinceId.toString());
Expand Down Expand Up @@ -1188,62 +1188,27 @@ public IHttpClient getHttpClient() {
}

/**
* @return your lists, ie. the one's you made.
* @deprecated use {@link Twitter_Lists#getLists(String)} or {@link Twitter_Lists#getLists(Long)}
*/
@Deprecated
public List<TwitterList> getLists() {
return getLists(name);
return lists().getLists(name);
}

/**
*
Returns <i>all</i> lists the authenticating or specified user subscribes to,
including their own.
@param user can be null for the authenticating user.
@see #getLists(String)
* @deprecated use {@link Twitter_Lists#getListsAll(String)} or {@link Twitter_Lists#getListsAll(Long)}
*/
public List<TwitterList> getListsAll(User user) {
assert user!=null || http.canAuthenticate() : "No authenticating user";
try {
String url = TWITTER_URL + "/lists/all.json";
Map<String, String> vars = user.screenName==null?
InternalUtils.asMap("user_id", user.id)
: InternalUtils.asMap("screen_name", user.screenName);
String listsJson = http.getPage(url, vars, http.canAuthenticate());
JSONObject wrapper = new JSONObject(listsJson);
JSONArray jarr = (JSONArray) wrapper.get("lists");
List<TwitterList> lists = new ArrayList<TwitterList>();
for (int i = 0; i < jarr.length(); i++) {
JSONObject li = jarr.getJSONObject(i);
TwitterList twList = new TwitterList(li, this);
lists.add(twList);
}
return lists;
} catch (JSONException e) {
throw new TwitterException.Parsing(null, e);
}
@Deprecated
public List<TwitterList> getListsAll(User user) {
return user.screenName==null? lists().getListsAll(user.id) : lists().getListsAll(user.screenName);
}

/**
* @param screenName
* @return the (first 20) lists created by the given user
* @deprecated use {@link Twitter_Lists#getLists(String)} or {@link Twitter_Lists#getLists(Long)}
*/
@Deprecated
public List<TwitterList> getLists(String screenName) {
assert screenName != null;
try {
String url = TWITTER_URL + "/" + screenName + "/lists.json";
String listsJson = http.getPage(url, null, true);
JSONObject wrapper = new JSONObject(listsJson);
JSONArray jarr = (JSONArray) wrapper.get("lists");
List<TwitterList> lists = new ArrayList<TwitterList>();
for (int i = 0; i < jarr.length(); i++) {
JSONObject li = jarr.getJSONObject(i);
TwitterList twList = new TwitterList(li, this);
lists.add(twList);
}
return lists;
} catch (JSONException e) {
throw new TwitterException.Parsing(null, e);
}
return lists().getLists(screenName);
}

/**
Expand All @@ -1253,6 +1218,7 @@ public List<TwitterList> getLists(String screenName) {
* @return lists of which screenName is a member. NOTE: currently limited to
* a maximum of 20 lists!
*/
// TODO: move to Twitter_Lists!
public List<TwitterList> getListsContaining(String screenName,
boolean filterToOwned) {
assert screenName != null;
Expand All @@ -1270,7 +1236,7 @@ public List<TwitterList> getListsContaining(String screenName,
List<TwitterList> lists = new ArrayList<TwitterList>();
for (int i = 0; i < jarr.length(); i++) {
JSONObject li = jarr.getJSONObject(i);
TwitterList twList = new TwitterList(li, this);
TwitterList twList = new TwitterList(li);
lists.add(twList);
}
return lists;
Expand All @@ -1285,6 +1251,7 @@ public List<TwitterList> getListsContaining(String screenName,
* @return lists that you are a member of. Warning: currently limited to a
* maximum of 20 results.
*/
// TODO: move to Twitter_Lists!
public List<TwitterList> getListsContainingMe() {
return getListsContaining(name, false);
}
Expand Down Expand Up @@ -1674,7 +1641,7 @@ public Status getStatus(String username) throws TwitterException {
* @param authenticate
* @return
*/
private List<Status> getStatuses(final String url, Map<String, String> var,
List<Status> getStatuses(final String url, Map<String, String> var,
boolean authenticate) {
// Default: 1 page
if (maxResults < 1) {
Expand Down Expand Up @@ -2912,4 +2879,11 @@ public Twitter_Users users() {
return new Twitter_Users(this);
}

/**
* List and membership/subscription related API methods.
*/
public Twitter_Lists lists() {
return new Twitter_Lists(this);
}

}
2 changes: 1 addition & 1 deletion src/winterwell/jtwitter/TwitterEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public TwitterEvent(JSONObject jo, Twitter jtwit) throws JSONException {
if (to == null)
return;
if (to.has("member_count")) {
targetObject = new TwitterList(to, jtwit);
targetObject = new TwitterList(to);
} else {
targetObject = to;
}
Expand Down
Loading