Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package facebook.insights; import facebook.metrics.Metricas; import java.io.FileOutputStream; import java.util.ArrayList; import java.util.List; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.json.JSONArray; import org.json.JSONObject; /** * * @author aaron */ public class Inicio { /** * @param args the command line arguments */ public static void main(String[] args) { // El Token solo dura 2 meses Metricas issuac = new Metricas( "CAAImAGMzn20BAF8yhGFZBNXP8LEnZCElzzSoX0Ll6uY1APzZBnAT9LVZCQ0dP1AKPxL8C1qybyyz7xfGCOLo3ew3W3IpJkZC8XNKvEsywyCCZBOaicIA1tQZCFWknQ1MdREu2BZCAoK3M0Y6yvm0whZCKgWrNHF4AuA8eSm8saoxIiUtqNFf3cq4F", "120472297979101"); Inicio obj = new Inicio(); try { // Se crea el libro Workbook libro = new XSSFWorkbook(); // Se crea una hoja dentro del libro Sheet hoja = libro.createSheet("Metricas 2014 by Flock"); // Se crea una fila dentro de la hoja Row fila = hoja.createRow(0); // Se crea una celda dentro de la fila Cell celda = fila.createCell(1); // Se crea el contenido de la celda y se mete en ella. celda.setCellValue("Insights X"); List<Row> filas = new ArrayList<>(); int recorrete = 1; for (int e = 2; e < 255; e++) { Row filad = hoja.createRow(e); filas.add(filad); } /************************************/ // Metrica // JSONObject ob = issuac.page_fan_removes(); JSONArray x = ob.getJSONArray("data"); JSONArray y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_fan_removes", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_fan_removes_unique(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_fan_removes_unique", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_fan_adds_by_paid_non_paid_unique(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_fan_adds_by_paid_non_paid_unique", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_fan_adds(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_fan_adds", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_fan_adds_unique(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_fan_adds_unique", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_views_login_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_views_login_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_views_login_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_views_login_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_views_login_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_views_login_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_views_login_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_views_login_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_views_logout_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_views_logout_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_views(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_views", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_tab_views_login_top_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_tab_views_login_top_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_tab_views_login_top_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_tab_views_login_top_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_tab_views_login_top_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_tab_views_login_top_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_tab_views_login_top_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_tab_views_login_top_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_tab_views_logout_top_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_tab_views_logout_top_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_views_external_referrals_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_views_external_referrals_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_story_type_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_story_type_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_story_type_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_story_type_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_story_type_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_story_type_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_story_type_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_story_type_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_story_type_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_story_type_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_story_type_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_story_type_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_age_gender_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_age_gender_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_age_gender_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_age_gender_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_age_gender_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_age_gender_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_country_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_country_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_country_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_country_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_country_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_country_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_locale_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_locale_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_locale_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_locale_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_locale_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_locale_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_city_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_city_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_city_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_city_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_city_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_city_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_age_gender_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_age_gender_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_age_gender_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_age_gender_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_country_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_country_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_country_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_country_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_country_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_country_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_city_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_city_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_city_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_city_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_city_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_city_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_locale_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_locale_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_locale_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_locale_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_locale_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_locale_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_paid_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_paid_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_paid_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_paid_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_paid_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_paid_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_paid_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_paid_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_paid_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_paid_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_paid_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_paid_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_organic_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_organic_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_organic_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_organic_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_organic_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_organic_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_organic_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_organic_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_organic_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_organic_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_organic_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_organic_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_viral_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_viral_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_viral_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_viral_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_viral_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_viral_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_viral_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_viral_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_viral_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_viral_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_viral_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_viral_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_story_type_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_story_type_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_story_type_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_story_type_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_story_type_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_story_type_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_story_type_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_story_type_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_story_type_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_story_type_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_story_type_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_story_type_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_paid_non_paid_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_paid_non_paid_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_paid_non_paid_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_paid_non_paid_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_paid_non_paid_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_paid_non_paid_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_paid_non_paid_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_paid_non_paid_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_paid_non_paid_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_paid_non_paid_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_paid_non_paid_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_paid_non_paid_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_total_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_total_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_total_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_total_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_total_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_total_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_total_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_total_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_total_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_total_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_total_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_total_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_mobile_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_mobile_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_mobile_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_mobile_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_mobile_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_mobile_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_mobile_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_mobile_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_mobile_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_mobile_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_mobile_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_mobile_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_paid_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_paid_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_paid_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_paid_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_paid_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_paid_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_paid_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_paid_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_paid_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_paid_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_paid_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_paid_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_organic_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_organic_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_organic_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_organic_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ FileOutputStream elFichero = new FileOutputStream("Metricas.xlsx"); libro.write(elFichero); elFichero.close(); } catch (Exception e) { System.err.println("Fallo" + e); } } private void recorre(int posicionColumna, String insight, Sheet hoja, JSONArray y, List<Row> fi) { int fila = 2; int columna = posicionColumna; Row filaT = fi.get(0); Cell celdaD = filaT.createCell(columna); celdaD.setCellValue(insight + ""); for (int i = 3, h = 0; h < y.length(); h++) { Row filaF = fi.get(i); System.out.println("i:" + i); Cell celdaE = filaF.createCell(columna); celdaE.setCellValue("" + y.getJSONObject(h).get("end_time")); JSONObject cd = new JSONObject(); try { cd = (JSONObject) y.getJSONObject(h).get("value"); } catch (Exception e) { System.err.println("No hay nada"); } if (cd.length() > 1) { for (int si = 0; si < cd.length(); si++) { filaF = fi.get(i + 1); Cell celdaF = filaF.createCell(columna + 1); celdaF.setCellValue("" + cd.names().getString(si)); celdaF = filaF.createCell(columna + 2); celdaF.setCellValue("" + cd.get(cd.names().getString(si))); i++; } } else { Cell celdaF = filaF.createCell(columna + 1); celdaF.setCellValue("" + y.getJSONObject(h).get("value")); } i++; } } }