I’m currently trying to create a wordpress plugin where i can trade bitcoins.
I should create a cron job where I want to check a value I get from some API calls, but my cron job isn’t activating properly.
I also tried to do some random “echo” to see if the problem is my API code but I think the problem is that wordpress isn’t activating my cron job.
This is my code:
function my_activation() {
if (!wp_next_scheduled ( 'my_periodic_event' )) {
wp_schedule_event(time(), 'thirtysec', 'my_periodic_event');
}
add_action('my_periodic_event', 'checkCurrencyValue');
}
function checkCurrencyValue() {
global $market, $quantita, $durata, $wpdb, $table_name;
$table_name = $wpdb->prefix."bittrex_account_info";
$users = $wpdb->get_results( "SELECT chiave FROM $table_name");
// The query will get the complete users login id/login name
foreach ( $users as $user ) {
echo $user->chiave;
}
$users = $wpdb->get_results( "SELECT chiave FROM $table_name WHERE email="filippomomente@gmail.com"");
$wpdb->update( $table_name, array( 'chiave' => $key, 'secret' => $users),array('email'=>'filippomomente@gmail.com'));
$d = new BittrexxApi ($key, $secret);
$quantita = $wpdb->get_var("SELECT quantita FROM wp_bittrex_account_info WHERE email="$mail"");
$discesaMax = $wpdb->get_var("SELECT discesaMax FROM wp_bittrex_account_info WHERE email="$mail"");
$maxValDol = $wpdb->get_var("SELECT maxvaldol FROM wp_bittrex_account_info WHERE email="$mail"");
$summ = $d->getMarketSummary("USDT-BTC");
if($summ<discesaMax){
//$balance = $d->buyLimit($market, $quantita, $durata);
}
else if($summ>maxValDol){
//$balance = $d->sellLimit($market, $quantita, $durata);
}
}
My register hook is working: the my_activation() function is executed but not the checkCurrencyValue() function.
Is there some problem?
Thank you in advance, Filippo