D
D
DenisParker102019-02-28 16:15:00
PHP
DenisParker10, 2019-02-28 16:15:00

How to download GIF document via vk api?

Hello! I can not download a file from the VK server via api vk.
Logic:
1. Using the wall.get method, I extract posts of interest to me
2. I extract direct links to pictures (in my case, giff)
3. Using the copy method, I upload data to my server
I tried this code to download pictures - everything works. The problem is only with gif (maybe other types of VK documents).

An example of a direct link to an image
https://sun9-21.userapi.com/c7003/v7003406/5f184/cZoV5R9rpdk.jpg

An example of a direct link to a gif
https://psv4.userapi.com/c848220/u114165366/docs/d2/c9e501e22af9/1a055e4802e726d9b4fe42fa4d9822a0_187945_1551001119.gif


The code:
$file = $imgUrl;
$host=__DIR__.'/new.gif';
if (!copy($file, $host)) {
    echo "не удалось скопировать $file\n";
}
chmod($host, 0777);

I understand that the copy (php) jpg method can be downloaded via a direct link, namely the document (gif) cannot be downloaded. Probably because of the access restriction (maybe not right). Can someone help or throw off a similar script.
I will be grateful!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question