This is my code for parse uploaded video list and it doesn’t work.
This url (https://api.twitch.tv/kraken/feed/erenjjing/posts?limit=50&client_id=myclientid) worked well, but this url (https://api.twitch.tv/kraken/channels/erenjjing/videos?broadcasts=true&limit=20&client_id=myClientID) doesn’t work.
How can i solve it?
HttpHandler sh = new HttpHandler();
String jsonStr = sh.makeServiceCall(https://api.twitch.tv/kraken/channels/erenjjing/videos?broadcasts=true&limit=20&client_id=myClientID);
String strPublished;
if (jsonStr != null) {
try {
JSONObject jsonObject = new JSONObject(jsonStr);
JSONArray videos = jsonObject.getJSONArray("videos");
for (int i = 0; i < videos.length(); i++)
{
VideoData videoData = new VideoData();
JSONObject json_data = videos.getJSONObject(i);
strPublished = json_data.getString(TAG_PUBLISHEDAT);
String replace_strPublished = strPublished.replace("T", " ").replace("Z", " ");
videoData.preview = json_data.getString(TAG_PREVIEW);
videoData.title = json_data.getString(TAG_TITLE);
videoData.published = json_data.getString(replace_strPublished);
videoData.url = json_data.getString(TAG_URL);
videoData.views = json_data.getString(TAG_VIEWS);
videoData.length = json_data.getString(TAG_LENGTH);
data.add(videoData);
}
} catch (final JSONException e) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
}
});
}
} else {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
}
});
}