I am using Botman Studio with PHP 7.4.22 from XAMPP bundle using php artisan serve.
I want image manipulation with Image Intervention and route it using web.php as jpg response.
This works in browser:
Route::get('img/{img_url}.jpg',function($img_url){
$img = ImageManagerStatic::make(base64_decode($img_url));
return $img->response();
});
But in Botman(both VK and Telegram) not works (say instead of reply, because it's inside conversation):
$photo_url = "http://*.ngrok.io/img/***.jpg";
$attachment = new Image( $photo_url );
$message = OutgoingMessage::create('')->withAttachment($attachment);
$this->say($message);
if I using REAL image file from public folder for example, not works too:
$photo_url = "http://*.ngrok.io/REAL_IMAGE.jpg";
$attachment = new Image( $photo_url );
$message = OutgoingMessage::create('')->withAttachment($attachment);
$this->say($message);
The only thing that somehow direct to problem this response in PowerShell:
Fatal error: Maximum execution time of 60 seconds exceeded in E:\YandexDisk\www\vapebot\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php on line 59
I think something blocks request from VK or Telegram to image, but I don't know what blocks it (VerifyCsrfToken * in $except - not helps too).
If I try to open the same link with the picture while the bot executes the attachment, then the browser also goes into "infinite loading".
I tried to google anything about this problem, but no luck, because there is no anything strange with code itself.
Evidence of this is that if I attach a picture from imgur(or clean folder without botman studio with image-file from another ngrok under ampps) for an example, then there are no problems and this works:
$photo_url = "https://i.imgur.com/b6MY9f8.jpeg";
$attachment = new Image( $photo_url );
$message = OutgoingMessage::create('')->withAttachment($attachment);
$this->say($message);
In tinker everything works too: Response preview using $img->save() Response preview using route with *.jpg
I even tried installing fresh Laravel, then require Botman (without studio) and Image Intervention - the same result :(
I also found code from VkCommunityCallbackDriver.php(maybe Telegram using same) that maybe coresponds to this problem, and trying to simulate it inside public dir also not works:
$data = file_get_contents("https://***.ngrok.io/img/***.jpg");
// ^ failed to open stream: HTTP request failed! ^
file_put_contents(__DIR__."/image.jpg",$data);
echo '<img src="image.jpg" />';