} $local_fans_country = file_get_contents('https://graph.facebook.com/' . $fila['fb_id'] . '/insights/page_fans_country?since=' . $since . '&until=' . $until . '&locale=es_LA&access_token=' . $access_token); $local_fans_country = json_decode($local_fans_country, true); //print_r($local_fans_country); if (isset($local_fans_country['data']) && $local_fans_country['data'][0]['name'] == 'page_fans_country') { $sql_insert = ''; $aux_first = true; foreach ($local_fans_country['data'][0]['values'] as $local_fan) { $date = explode('T', $local_fan['end_time']); if (!is_exist_fb_page_local_fan_date($id_page, $date[0])) { foreach ($local_fan['value'] as $key => $value) { $_country_id = get_country_id_from_code($key); if (!empty($_country_id)) { if (!$aux_first) { $sql_insert .= ','; } else { $aux_first = false; } $sql_insert .= "(NULL, " . mysql_real_escape_string($id_page) . "," . mysql_real_escape_string($_country_id) . "," . mysql_real_escape_string($value) . ",'" . mysql_real_escape_string($date[0]) . "')"; } } } } if (!empty($sql_insert)) { add_lote_fb_page_local_fan($sql_insert); } else { echo '<br>No se actualizó: <a href="http://www.owloo.com/facebook-stats/pages/' . $fila['username'] . '/">' . $fila['username'] . '</a><br>'; } } update_fb_page_local_fans($id_page, get_first_country_local_fans($id_page)); }
foreach ($local_fan['value'] as $key => $value) { $_country_id = get_country_id_from_code($key); if (!empty($_country_id)) { if (!$aux_first) { $sql_insert .= ','; } else { $aux_first = false; } $sql_insert .= "(NULL, " . mysql_real_escape_string($id_page) . "," . mysql_real_escape_string($_country_id) . "," . mysql_real_escape_string($value) . ",'" . mysql_real_escape_string($date[0]) . "')"; } } } if (!empty($sql_insert)) { add_lote_fb_page_local_fan($sql_insert); } } update_fb_page_likes_talking_about_local_fans($id_page, $datos['likes'], $datos['talking_about_count'], get_first_country_local_fans($id_page)); } else { $mensaje_new_fan_page = '<div>Lo sentimos, <strong>no hemos podido procesar su petición</strong>.</div> <div>Favor, intentelo más tarde...</div>'; } } } else { $mensaje_new_fan_page = "<div>Puede que <strong>" . $__page . "</strong> no esté registrado en Facebook.</div>\n <div>Favor verifique la página ingresada y vuelve a intentarlo!</div>"; } } else { $mensaje_new_fan_page = "<div>Puede que <strong>" . $__page . "</strong> no esté registrado en Facebook.</div>\n <div>Favor verifique la página ingresada y vuelve a intentarlo!</div>"; } echo '<br>' . $mensaje_new_fan_page . '<br>'; } }