Telegram BOT Api: how to send a photo using PHP?

后端 未结 6 1821
臣服心动
臣服心动 2020-12-24 09:32

The sendPhoto command require an argument photo defined as InputFile or String.

The API doc tells:

Photo to send. You can          


        
6条回答
  •  失恋的感觉
    2020-12-24 10:05

    This a bad idea, but you can use some like that:

    #!/bin/bash
    
    set -x
    set -e
    
    BDIR=/tmp/${RANDOM}
    TG_TOKEN=""
    TG_CHAT_ID=
    
    mkdir -p ${BDIR}
    chmod -R 777 ${BDIR}
    su postgres -c "pg_dumpall -f ${BDIR}/postgre.sql"
    tar czf ${BDIR}/${HOSTNAME}.tar.gz /var/lib/grafana/ /etc/grafana/ ${BDIR}/postgre.sql
    
    
    curl -F caption="$(date)" -F chat_id="${TG_CHAT_ID}" -F document=@"${BDIR}/${HOSTNAME}.tar.gz" https://api.telegram.org/bot${TG_TOKEN}/sendDocument
    
    rm -rf ${DBIR}
    

提交回复
热议问题