C
C
crack_user2021-08-13 17:22:14
PHP
crack_user, 2021-08-13 17:22:14

How to download a photo to the server from vk?

This is what the response looks like when sending a message with a photo

"type": "message_new",
    "object": {
        "message": {
            "date": 1628863980,
            "from_id": 123,
            "id": 30430,
            "out": 0,
            "peer_id": 123,
            "text": "",
            "conversation_message_id": 17348,
            "fwd_messages": [],
            "important": false,
            "random_id": 0,
            "attachments": [
                {
                    "type": "photo",
                    "photo": {
                        "album_id": -7,
                        "date": 1605377976,
                        "id": 457254130,
                        "owner_id": 123,
                        "has_tags": false,
                        "access_key": "123,
                        "sizes": [
                            {
                                "height": 97,
                                "url": "http://fdsfsldkfskldfsd.jpg",
                                "type": "m",
                                "width": 130
                            },

And I need to get the url link, but the trouble is that there are several sizes of the image ("height": 97), I need to get a
photo with a size of 300 (as I understand it, it is the original)
{
                                "height": 300,
                                "url": "https://sun9dasdsa",
                                "type": "x",
                                "width": 400
                            }

Tried -
$url = $data->object->message->attachments[0]->photo->sizes->height[300]->url;
и через if($height=='300)

none of this helped.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stockholm Syndrome, 2021-08-13
@StockholmSyndrome

How to select biggest photo in vk api photos.get array?
be sure to read the comments

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question