if (count($row) == 0) {
     $ban = 0;
     while ($ban == 0) {
         //Audiencia total
         $check_audience = false;
         $numAudience = NULL;
         while (!$check_audience) {
             $numAudience = getNumAudience($next_code, $key_language, $accessToken, $accountId, $pageId, $pageName);
             if (!$numAudience) {
                 nextAccessToken();
             } else {
                 $check_audience = true;
             }
         }
         if (is_numeric($numAudience)) {
             cassandra_insert("INSERT INTO facebook_record_country_language(id_country,id_language,total_user,date,date_time) VALUES({$next_id}, {$id_language}, {$numAudience}, {$date}, dateof(NOW()));");
             $ban = 1;
         } else {
             send_email('country_language', 'Owloo ERROR - Pais LANGUAGE - ' . $fila['id_country'], 'ERROR en la captura de datos.', true, 'Captura de datos - Pais LANGUAGE - ID = ' . $_SERVER['argv'][1] . ' => ' . $numAudience);
         }
     }
     /***************************************** FIN GET TOTALES ********************************************************/
     /********************************** Verificación de finalización *************************************************/
     //Cantidad de filas insertadas
     $inserts = cassandra_query("SELECT COUNT(*) FROM facebook_record_country_language WHERE date = {$date};");
     if (count($inserts) > 0) {
         if ($inserts[0]['count'] == $total_language) {
             send_email('country_language', 'Owloo EXITO - Pais LANGUAGE', 'EXITO en la captura de datos.');
         }
     }
     /******************************* FIN - Verificación de finalización **********************************************/
Ejemplo n.º 2
0
function register_error($type, $error)
{
    global $cassandra_db;
    $date = date('Ymd');
    cassandra_insert("INSERT INTO owloo_cron_error_info(type,error,date) VALUES('{$type}', '{$error}', {$date});");
}
Ejemplo n.º 3
0
             $check_audience = true;
         }
     }
     //Audiencia total hombres
     $check_audience = false;
     $numAudienceMale = NULL;
     while (!$check_audience) {
         $numAudienceMale = getNumAudience($next_code, $age_min, $age_max, "1", $accessToken, $accountId, $pageId, $pageName);
         if (!$numAudienceMale) {
             nextAccessToken();
         } else {
             $check_audience = true;
         }
     }
     if (is_numeric($numAudience) && is_numeric($numAudienceMale) && is_numeric($numAudienceFemale)) {
         cassandra_insert("INSERT INTO facebook_record_country_age(id_country,id_age,total_user,total_female,total_male,date,date_time) VALUES({$next_id}, {$age_id}, {$numAudience}, {$numAudienceFemale}, {$numAudienceMale}, {$date}, dateof(NOW()));");
         $ban = 1;
     } else {
         send_email('country_age', 'Owloo ERROR - Pais AGE - ' . $next_id, 'ERROR en la captura de datos.', true, 'Captura de datos - Pais AGE - ID = ' . $_SERVER['argv'][1] . ' => ' . $numAudience . ' - ' . $numAudienceFemale . ' - ' . $numAudienceMale);
     }
 }
 /***************************************** FIN GET TOTALES ********************************************************/
 /********************************** Verificación de finalización *************************************************/
 //Cantidad de filas insertadas
 $inserts = cassandra_query("SELECT COUNT(*) FROM facebook_record_country_age WHERE date = {$date};");
 if (count($inserts) > 0) {
     if ($inserts[0]['count'] == $total_age_rows) {
         send_email('country_age', 'Owloo EXITO - Pais AGE', 'EXITO en la captura de datos.');
     }
 }
 /******************************* FIN - Verificación de finalización **********************************************/
function setAccessToken()
{
    $accounts = cassandra_query('SELECT email, accountid, pass FROM facebook_access_token_account;');
    $ban = false;
    foreach ($accounts as $fila) {
        if (file_exists('/home/owloo/public_html/wservice/access_token_cassandra/cookie/cookies.txt')) {
            unlink('/home/owloo/public_html/wservice/access_token_cassandra/cookie/cookies.txt');
        }
        $f = fopen('/home/owloo/public_html/wservice/access_token_cassandra/cookie/cookies.txt', 'w');
        $access_token = getAccessToken_code($fila['email'], $fila['pass']);
        if (!$access_token) {
            $access_token = getAccessToken_code($fila['email'], $fila['pass']);
        }
        if ($access_token) {
            /*if(file_exists('/home/owloo/public_html/wservice/access_token/cookie/cook.txt')) unlink('/home/owloo/public_html/wservice/access_token/cookie/cook.txt');
            		$f = fopen('/home/owloo/public_html/wservice/access_token/cookie/cook.txt', 'w');
            		$access_token_expire = getAccessTokenExpireDate($access_token);
            		if(!$access_token_expire)
            			$access_token_expire = getAccessTokenExpireDate($access_token);*/
            //$sql = "INSERT INTO access_token VALUES (NULL , '".$access_token."', '".$fila['accountId']."', ".date('U').", ".$access_token_expire.");";
            cassandra_insert("INSERT INTO facebook_access_token(access_token,accountid,date_in,date_out,date_add) VALUES('{$access_token}', '" . $fila['accountid'] . "', " . date('U') . ", " . (date('U') + 36000) . ", dateof(now()));");
            $ban = true;
        }
    }
    /*if(!$ban)
    		informarError();*/
}