0

I am trying to push a certain plain text as notification to users through telegram bot using the below mentioned segment of code. The issue that I am facing is that message is not getting pushed out at a given time. Please let me know what can I do. Any articles that I can read or go through.

The value of time obtained by me after echoing $time is correct.

I am coding in PHP

<?php
    date_default_timezone_set('Asia/Kolkata');
    $time = date("h:i:sa");
    $timezone = date("e");
    if ($time == "12:00:00pm") {
        $request_url =  $website."/sendMessage?chat_id=745775755&text=<b>You are receiving this message as a notification&disable_web_page_preview=true&parse_mode=HTML";
        file_get_contents($request_url);
    }
?>

Is there any way to automate it and send this regularly at 12:00:00pm whenever this if condition holds true?

Tarun Jain
  • 23
  • 5
  • 1
    Look into cron jobs. Remove the seconds from the check, though, as it may not run right at :00. In fact, it tends to run at :01 on my system. – aynber Dec 03 '19 at 14:01

1 Answers1

0

Thanks for answering my question.

I was able to get my hands on EasyCRON. After linking it to my PHP file online on the server, I triggered a url reload through it for every minute. This will in turn send out a push message like I wanted.

Readers, please free to put in questions.

Cheers!

Tarun Jain
  • 23
  • 5