首页 > 解决方案 > 在linux服务器上发送php图像

问题描述

我有一个 php 机器人,可以发送图片。现在我将它从 Heroku 移到了 Rasberry pi 4 上的 apache 2。效果很好,但我根本无法发送图片。(我可以在heroku上)。Bot 可以访问文件夹,可以从 Internet 保存文件,创建新文件,但不能发送它们。可能是什么问题呢?

我认为代码不是问题,但我把它留在这里

    public function sendImage($id, $local_file_path)
    {
        $upload_url = $this->sendDocuments($id, 'photo')['upload_url'];
        $answer_vk = json_decode($this->sendFiles($upload_url, $local_file_path, 'photo'), true);
        $upload_file = $this->savePhoto($answer_vk['photo'], $answer_vk['server'], $answer_vk['hash']);
        $this->request('messages.send', array('attachment' => "photo" . $upload_file[0]['owner_id'] . "_" . $upload_file[0]['id'], 'peer_id' => $id));
        return 1;
    }
}
$img_dir=__DIR__ . "/img/";
$vk->sendImage($peer_id, $img_dir."Raid.jpg", "Raid.jpg");

标签: phplinuxbotsvk

解决方案


推荐阅读