0

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" />';
ale24
  • 1
  • 2
  • it's looks like it hardcoded in packages that VK-Driver uploads file itself, but Telegram-Driver just pass URL to image, so if I even used public_path('image.jpg'), I can't use same on Telegram... but if used image URL from same host it's simple FREEZE to infinite on both Drivers, OMG... vendor\yageorgiy\botman-vk-community-callback-driver\src\VkCommunityCallbackDriver.php `$uploadImg = $this->upload($getUploadUrl["response"]['upload_url'], $attachment->getUrl()); ` vendor\botman\driver-telegram\src\TelegramDriver.php: `$parameters['photo'] = $attachment->getUrl();` – ale24 Sep 02 '21 at 12:00
  • tried add Reponse headers using this https://stackoverflow.com/questions/39429462/adding-access-control-allow-origin-header-response-in-laravel-5-3-passport not works too :( – ale24 Sep 02 '21 at 12:23
  • I found only one soultion - removing Laravel and leave it for artisans... with clean botman+intervention image+drivers both telegram and vk works as expected and all images attaching no matter fake or presaved – ale24 Sep 02 '21 at 19:26

0 Answers0