}
    }
}
$query = "SELECT id_page, fb_id \n                FROM  facebook_page\n                WHERE date_update < date_format(NOW(), '%Y-%m-%d')\n                ORDER BY 1\n                ;";
$que = mysql_query($query) or die(mysql_error());
$cont = 0;
$_aux_count = 0;
$sql_in = '';
$sql_insert = '';
while ($fila = mysql_fetch_assoc($que)) {
    $_aux_count++;
    $array_fb_id_to_id_page[$fila['fb_id']] = $fila['id_page'];
    $cont++;
    if ($cont != 1) {
        $sql_in .= ',';
    }
    $sql_in .= $fila['fb_id'];
    if ($cont == 500) {
        cron_update_page_details_from_fb($sql_in);
        $cont = 0;
        $sql_in = '';
    }
}
if ($cont > 0) {
    cron_update_page_details_from_fb($sql_in);
}
$query = "SELECT count(*) count \n                FROM  facebook_page\n                WHERE date_update < date_format(NOW(), '%Y-%m-%d')\n                ORDER BY 1\n                ;";
$que = mysql_query($query) or die(mysql_error());
if ($fila = mysql_fetch_assoc($que)) {
    enviar_informe($fila['count'], $_aux_count);
}
Exemple #2
0
    $data[] = 0;
    while ($fila = mysql_fetch_assoc($result)) {
        $data[] = $fila[$column];
    }
    return implode(',', $data);
}
define('INSTAGRAM_CLIENT_ID', '04e770ce699e44eb80bcf26cf929aa5a');
define('INSTAGRAM_COUNT_DATA', 100);
function instagram_user_data($user_id)
{
    $data = get_url_content("https://api.instagram.com/v1/users/{$user_id}/?client_id=" . INSTAGRAM_CLIENT_ID);
    return json_decode($data, true);
}
$query = 'SELECT id_profile, instagram_id FROM `instagram_profiles`';
$que = db_query($query, array());
$total_profile = mysql_num_rows($que);
$query = 'SELECT id_profile, instagram_id FROM `instagram_profiles` WHERE id_profile NOT IN(' . get_data_for_sql_in('SELECT id_profile FROM `instagram_record` WHERE `date` = DATE(NOW())', 'id_profile') . ') ORDER BY 1';
$que = db_query($query, array());
$total_profile_before = mysql_num_rows($que);
while ($fila = mysql_fetch_assoc($que)) {
    $user_data = instagram_user_data($fila['instagram_id']);
    if ($user_data['meta']['code'] == 200) {
        $query = 'INSERT INTO instagram_record VALUES($1, $2, $3, $4, NOW());';
        $row = db_query($query, array($fila['id_profile'], $user_data['data']['counts']['media'], $user_data['data']['counts']['followed_by'], $user_data['data']['counts']['follows']), 1);
    }
}
$query = 'SELECT id_profile, instagram_id FROM `instagram_profiles` WHERE id_profile NOT IN(' . get_data_for_sql_in('SELECT id_profile FROM `instagram_record` WHERE `date` = DATE(NOW())', 'id_profile') . ') ORDER BY 1';
$que = db_query($query, array());
$total_profile_after = mysql_num_rows($que);
enviar_informe($total_profile, $total_profile_before, $total_profile_after);