java - Get comments of Instagram photo -
i'm trying comments instagram photos. works, except prints first 8 comments. based code off of http://www.ibm.com/developerworks/xml/library/x-instagram1/index.html, in theory should work (there's done in php). there's stupid mistake in mine somewhere, if point out appreciate bunches <3.
// construct url instagram feed maccesstoken = sharedpref.getstring(api_access_token, null); // todo: have switch -1, right? string feed = "https://api.instagram.com/v1/users/self/feed?access_token="+maccesstoken; // making request url , getting response string json = sh.makeservicecall(feed, servicehandler.get); // stuff if (json != null) { try { // make new json object jsonobject obj = new jsonobject(json); // data data = obj.getjsonarray(tag_data); // looping through data (int i=0; < data.length(); i++) { jsonobject c = (jsonobject)data.get(i); jsonobject img = c.getjsonobject(tag_images); jsonobject thum = img.getjsonobject(tag_low_resolution); jsonobject comments = c.getjsonobject(tag_comments); jsonobject user = c.getjsonobject(tag_user); jsonobject likes = c.getjsonobject(tag_likes); string likes_count = likes.getstring(tag_likes_count); string profile_picture = user.getstring(tag_profile_picture); string username = user.getstring(tag_username); string comments_count = comments.getstring(tag_comments_count); system.out.println(comments_count); string urlofpic = thum.getstring(tag_url); jsonarray comments_data = comments.getjsonarray("data"); (int z=0; z < comments_data.length(); z++) { string commenttext = ((jsonobject) comments_data.get(z)).getstring("text").tostring(); system.out.println("commenttext ==" +commenttext); long created_time = long.parselong((((jsonobject) comments_data.get(z)).getstring("created_time")).tostring()); date date = new date(created_time * 1000); system.out.println(date); } system.out.println("-------------------------------------------------------------"); hashmap<string, string> photos = new hashmap<string, string>(); photos.put("likes.count", likes_count); photos.put(tag_profile_picture, profile_picture); photos.put(tag_username, username); photos.put(tag_url, urlofpic); photos.put(tag_comments_count, comments_count); instagram_list.add(photos); } } catch (jsonexception ex) { ex.printstacktrace(); } }
Comments
Post a Comment