hello...
I make a photo in another file with php,
and I try to send photo:
$response = $telegram->sendPhoto([
'chat_id' => -1001066838580,
'photo' => "https://gentle-earth-84565.herokuapp.com/distich-maker/randomDistich.php?m1=".$request->m1."&m2=".$request->m2."&poet=".$request->poet
]);
and the maked url like this:
https://example-84565.herokuapp.com/distich-maker/randomDistich.php?m1=%D9%BE%DB%8C%D8%B1%20%D9%BE%DB%8C%D9%85%D8%A7%D9%86%D9%87%E2%80%8C%DA%A9%D8%B4%20%D9%85%D9%86%20%DA%A9%D9%87%20%D8%B1%D9%88%D8%A7%D9%86%D8%B4%20%D8%AE%D9%88%D8%B4%20%D8%A8%D8%A7%D8%AF&m2=%DA%AF%D9%81%D8%AA%20%D9%BE%D8%B1%D9%87%DB%8C%D8%B2%20%DA%A9%D9%86%20%D8%A7%D8%B2%20%D8%B5%D8%AD%D8%A8%D8%AA%20%D9%BE%DB%8C%D9%85%D8%A7%D9%86%E2%80%8C%D8%B4%DA%A9%D9%86%D8%A7%D9%86&poet=%D8%AD%D8%A7%D9%81%D8%B8
the parameters is in persian language.
but this says:
Bad Request: Wrong persistent file_id specified: contains wrong characters or has wrong length
Hello, you should be doing something like this:
$this->telegram()->sendPhoto([
'photo' => new InputFile($pathToPhoto)
]);
I do this...
but this error:
ErrorException in Api.php line 983:
is_file() expects parameter 1 to be a valid path, object given
https://telegram-bot-sdk.readme.io/docs/sendphoto
use Telegram\Bot\Api;
$telegram = new Api('BOT TOKEN');
$response = $telegram->sendPhoto([
'chat_id' => 'CHAT_ID',
'photo' => 'path/to/photo.jpg',
'caption' => 'Some caption'
]);
$messageId = $response->getMessageId();
Worked for me.
Hi,
You need to supply a local realpath of the photo instead of a remote URL
Actually the api says you can use an url and not just a real path.
https://telegram-bot-sdk.readme.io/docs/sendphoto
I think URL validation in SDK is unable to consider that remote URL as valid. I'll look into it and see what we can do about it. Perhaps, You can just do file_get_contents($url) and pass on the data, It supports resource data too.
I just rewrote the way we handle file uploads after several tests and going through different solutions.
This commit 8fb5bf4 makes a major change to the way files should be uploaded (Including remote).
@mmnaderi If you'd like to start testing, you can pull in the dev-develop branch for now and test with the following code (These changes will be released when V3 is tagged and will also be documented):
use Telegram\Bot\FileUpload\InputFile; // Import at the top.
$remoteImage = 'http://domain.com/path/to/image.jpg'.
$filename = 'my-photo.jpg'; // This is mandatory for remote or resource file uploads.
// Assuming that $tg, is a Telegram API instance
$tg->sendPhoto( [
'chat_id' => '99999999',
'photo' => InputFile::create($remoteImage, $filename),
'caption' => 'This is a caption',
] );
P.S. I'm closing this issue for now but you may comment here or create another issue (Should you face any other issues).
Most helpful comment
I just rewrote the way we handle file uploads after several tests and going through different solutions.
This commit 8fb5bf4 makes a major change to the way files should be uploaded (Including remote).
@mmnaderi If you'd like to start testing, you can pull in the
dev-developbranch for now and test with the following code (These changes will be released when V3 is tagged and will also be documented):P.S. I'm closing this issue for now but you may comment here or create another issue (Should you face any other issues).