dongrao9454 2019-06-08 05:20 采纳率: 100%
浏览 144

如何使用PHP每分钟向电报机器人发送通知?

The scenario is as follows, I want to send messages or notifications (without commands sent by users) every minute on a Telegram channel.

It happens that I can send the messages every time I enter the URL and the message is sent, but I want it to be sent automatically (without entering the URL) every minute. I do not know how to do that, thanks in advance.

<?php $botToken="<<BOT-TOKEN>>" ; $website="https://api.telegram.org/bot" .$botToken; $chatId="337957895" ; //**===>

NOTE: this chatId MUST be the chat_id of a person, NOT another bot chatId !!!** $params=[ 'chat_id'=>$chatId, 'text'=>'This is my message !!!', ]; $ch = curl_init($website . '/sendMessage'); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, ($params)); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); curl_close($ch); ?>

I have to enter the URL still for the message to be sent ... https://bot.unpixelmas.com/bot.php

  • 写回答

1条回答 默认 最新

  • dongru2019 2019-07-25 20:36
    关注

    If the URL is always the same, you should use cronjob and set it to open that URL every minute.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于双目测规则物体尺寸
  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,