curl_setopt($ch, CURLOPT_HEADER, [
':authority: vk.com',
':method: GET',
':path: /video-35485992_456239186',
':scheme: https',
'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'accept-encoding: gzip, deflate, br',
'accept-language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7,uk;q=0.6',
'cookie: tmr_lvid=342feefaca7fad045c73235048717475; tmr_lvidTS=1624387810868; _ga=GA1.2.1600500250.1638356280; _fbp=fb.1.1643652994571.1158429612; remixlang=0; remixQUIC=1; remixlgck=946a39f0537309eac6; remixflash=0.0.0; remixscreen_width=1536; remixscreen_height=864; remixscreen_dpr=1.25; remixscreen_depth=24; remixscreen_orient=1; remixdt=7200; remixttpid=c0478841a6f2cab6c3694d51dc64d19fa7aa16325c; remixseenads=0; remixstid=47223199_QKA7SRAQPtyOZMqjvxiJe4snhd9sHXhRO06isBdikxc; remixuas=93196849db48d84663b65c7217c327df; remixua=41%7C-1%7C194%7C3261248227; remixluas2=ZTAzZGRlNTIwNjQ5YTg1OGNlODMzMGU5; remixgp=5953ad7b68b092856936f3487a33692c; remixscreen_winzoom=1; remixnsid=cf354bf23925d45f49c51cec7979645cc9ef32e637b2ae3e98d4763f36d7937a29e9202217aa74b9378c9; remixrefkey=7007b77b93ee90f605; remixsid=1_m-Le0xshN_IMaDO7ACuSMcxTgjcCd0Q6E6ayqBdApkhb57QhQ-cTUmSM7y3ILuDr_V2camCgHkQTfraDh_xm_w; remixmdv=7qBp5yZRrWaMdom0; remixaudio_show_alert_today=0; remixmdevice=1536/864/1.25/!!-!!!!!; remixdark_color_scheme=0; remixcolor_scheme_mode=auto; remixff=1011111111; remixcurr_audio=undefined; remixmvk-fp=49827f876ea9228fa861f3f90b3efb6b; remixstickers_hash=b153b89acd217aca135b929397c2d977@1; tmr_reqNum=4536; tmr_detect=0%7C1645999063199',
'sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="98", "Google Chrome";v="98"',
'sec-ch-ua-mobile: ?0',
'sec-ch-ua-platform: "Windows"',
'sec-fetch-dest: document',
'sec-fetch-mode: navigate',
'sec-fetch-site: none',
'sec-fetch-user: ?1',
'upgrade-insecure-requests: 1',
'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36'
]
$json = '{
"type": "wall_post_new",
"object": {
"id": 9866,
"from_id": -71359952,
"owner_id": -71359952,
"date": 1634887159,
"marked_as_ads": 0,
"post_type": "post",
"text": "",
"can_edit": 1,
"created_by": 116945277,
"can_delete": 1,
"attachments": [
{
"type": "photo",
"photo": {
"album_id": -7,
"date": 1634887159,
"id": 457241606,
"owner_id": -71359952,
"has_tags": false,
"access_key": "cb9d26302dbe848cbe",
"post_id": 9866,
"sizes": [
{
"height": 56,
"url": "https://sun9-61.userapi.com/impg/kT2hBFeQbJtkSDVkErgZcQqDa65t576q_rhFqg/Q0GSfP8lZ-w.jpg?size=75x56&quality=96&sign=868a37e799d37e5fb909f9e186ae60c7&c_uniq_tag=z8NuyILfprRgfB0eZvHfvmTZZWEiriqy0mYP7f9VcW0&type=album",
"type": "s",
"width": 75
},
{
"height": 97,
"url": "https://sun9-61.userapi.com/impg/kT2hBFeQbJtkSDVkErgZcQqDa65t576q_rhFqg/Q0GSfP8lZ-w.jpg?size=130x97&quality=96&sign=c6fc81be08ce2cb7a6f754b35be76915&c_uniq_tag=A2J3HZUMufj0cJbKmWydc7rWgLFuj-6sJjWQzB8tPXw&type=album",
"type": "m",
"width": 130
},
{
"height": 453,
"url": "https://sun9-61.userapi.com/impg/kT2hBFeQbJtkSDVkErgZcQqDa65t576q_rhFqg/Q0GSfP8lZ-w.jpg?size=604x453&quality=96&sign=cb174bb4cef4714e3430eeea10f3798f&c_uniq_tag=zfWu4cM1neZkNavndNJGEInUsLpolBLJIN2bcggsKdY&type=album",
"type": "x",
"width": 604
},
{
"height": 600,
"url": "https://sun9-61.userapi.com/impg/kT2hBFeQbJtkSDVkErgZcQqDa65t576q_rhFqg/Q0GSfP8lZ-w.jpg?size=800x600&quality=96&sign=acd2276f681fb6ffacfb0101a4bb842a&c_uniq_tag=U-1syIvgxzIAp9Ru3reLZxQtwaYNEedgZEsuSyG9s0s&type=album",
"type": "y",
"width": 800
},
{
"height": 98,
"url": "https://sun9-61.userapi.com/impg/kT2hBFeQbJtkSDVkErgZcQqDa65t576q_rhFqg/Q0GSfP8lZ-w.jpg?size=130x97&quality=96&sign=c6fc81be08ce2cb7a6f754b35be76915&c_uniq_tag=A2J3HZUMufj0cJbKmWydc7rWgLFuj-6sJjWQzB8tPXw&type=album",
"type": "o",
"width": 130
},
{
"height": 150,
"url": "https://sun9-61.userapi.com/impg/kT2hBFeQbJtkSDVkErgZcQqDa65t576q_rhFqg/Q0GSfP8lZ-w.jpg?size=200x150&quality=96&sign=d0bad8f3add2f7268adb34554ec7b9a0&c_uniq_tag=fV6ckMyltJT5oLv9SHG3aEXx57dHwVCki-YxmbcvLb0&type=album",
"type": "p",
"width": 200
},
{
"height": 240,
"url": "https://sun9-61.userapi.com/impg/kT2hBFeQbJtkSDVkErgZcQqDa65t576q_rhFqg/Q0GSfP8lZ-w.jpg?size=320x240&quality=96&sign=e9a566a9729a268e7995703208ad4529&c_uniq_tag=Lbt6tO5HC90FOkrGqEXN8tXhj1j-vATVQCdyDPieGuw&type=album",
"type": "q",
"width": 320
},
{
"height": 383,
"url": "https://sun9-61.userapi.com/impg/kT2hBFeQbJtkSDVkErgZcQqDa65t576q_rhFqg/Q0GSfP8lZ-w.jpg?size=510x382&quality=96&sign=ac173b9f8751c1f24eb31e29a91b4802&c_uniq_tag=DLk8fz5i-6i0zPyPXEuSFPeziAa4XXnmFeic5IqGw8A&type=album",
"type": "r",
"width": 510
}
],
"text": "Original: https://sun9-75.userapi.com/impg/6zjQRArEef0zbzQJufzoCXG-NTAOK-qxLuXSKQ/Gpit0s4jt8E.jpg?size=800x600&quality=96&sign=99925aedab978f76600299495339a5c7&type=album",
"user_id": 100
}
}
],
"comments": {
"count": 0
},
"is_favorite": false,
"donut": {
"is_donut": false
},
"short_text_rate": 0.8,
"hash": "1xICO6GMEm8c_0q97fYx4toJowvE"
},
"group_id": 71359952,
"event_id": "d9600e5aa3478718411576f5f671b3a63bdc67e9",
"secret": "3e06befe555ef3f4773f285fd6ec0c508c866073"
}';
$json = json_decode($json);
$photo_original = '';
foreach($json->object->attachments[0]->photo->sizes as $photo) {
if(
$photo->type == "w" ||
$photo->type == "z" ||
$photo->type == "y" ||
$photo->type == "r" ||
$photo->type == "q" ||
$photo->type == "p" ||
$photo->type == "o" ||
$photo->type == "x" ||
$photo->type == "m" ||
$photo->type == "s"
) {
$photo_original = $photo->type;
}
$json_attach = array(
'type' => 'link',
'url' => $photo_original
);
}
echo $photo_original; // Выведет r, а должен y