php-telegram-bot / core

PHP Telegram Bot based on the official Telegram Bot API
MIT License
3.9k stars 953 forks source link

dont send photo #268

Closed pedram1992 closed 8 years ago

pedram1992 commented 8 years ago
$data['chat_id'] = $query->getMessage()->getChat()->getId();
$path = realpath('/Calendar.png');
Request::sendPhoto($data, $path);

Hi, i used Request::sendPhoto($data, $path) for send photo from local ,but don't send photo to user.

imidazil commented 8 years ago
$telegram->setUploadPath(__DIR__ . "/Uploads");
$data = [
    'chat_id' => $chat_id
];
$result = Request::sendPhoto($data, $telegram->getUploadPath() . "/image.jpg");
noplanman commented 8 years ago

Hi!

I think the path to the file is wrong. Are you sure the path to Calendar.png is correct? It's searching for it in the / root folder, not the current one.

Try this if the file is in the current folder:

$path = realpath(__DIR__ . '/Calendar.png');

You can also enable logging to help find the problem.

Edit: @imidazil beat me to it

pedram1992 commented 8 years ago

@noplanman @imidazil i tried many paths but not solve my problem ( __DIR__ or __FILE__ ) do you test SendPhoto to your project with local photo? i checked error log and don't have any error

jacklul commented 8 years ago

Maybe you're not using newest library version?

noplanman commented 8 years ago

Before calling Request::sendPhoto, add this line to make sure that the path is valid.

Longman\TelegramBot\TelegramLog::debug($path);

Then check your debug log file and check that the correct path is output.

As @jacklul mentions, what version of the library are you using?

Also, remember to return the result at the end of your commands execute() method.

I assume that all other commands work properly as they should?

pedram1992 commented 8 years ago

@jacklul i got it in 17 jul 2016. @noplanman i checked debug log, i faced with Bad Request: there is no photo in the request error. all of commands work properly.

noplanman commented 8 years ago

Ok, then the version will be the problem.

The photo sending was fixed in version 0.35, you probably still have 0.34.

When you run the /help command, it tells you which version you have.

pedram1992 commented 8 years ago

thanks @noplanman , i should update my akalongman to .035