AleksMey
@AleksMey
Пытаюсь разобраться

Почему не работает вывод картинок в скрипте постинга в соц сети?

Хочу сделать автоматический постинг shortstory вк (DLE). Друг помог написать часть кода, но сам код не может выводить медиа вк, постит только текст. Помогите кто может исправить хотя бы баг из-за которого не выводит картинки вк, а если не сложно то и доделать скрипт.

<?php
   

            // Need to have the vk.php in the same directory.
            include 'vk.php';
        
            // Please complete the below with your details/credentials.
            $config['secret_key'] = 'ключ';
            $config['client_id'] = '-7647836';
            $config['user_id'] = '-185764440';
            $config['access_token'] = 'токен';
            $config['scope'] = 'wall,photos,friends,groups';
        
            // Get a new instance of VK.
            $v = new Vk($config);
        
            // Define the attachment to insert, in this case an image.
            $attachments = $v->upload_photo(0, array('test.jpg'));
        
            // Post the message and image to your wall.
            $response = $v->wall->post(array(
               'message'=>'test 1737759.jpg',
               'attachments' => implode(',', $attachments)
            ));
        
    


            // $curl = curl_init();
            // curl_setopt_array($curl, [
            //     CURLOPT_URL => 'https://api.vk.com/method/wall.post',
            //     CURLOPT_POST => true,
            //     CURLOPT_SSL_VERIFYPEER => false,
            //     CURLOPT_SSL_VERIFYHOST => false,
            //     CURLOPT_RETURNTRANSFER => true,
            //     CURLOPT_POSTFIELDS => [
            //         'owner_id' => '-185764440',
            //         'message' => 'text',
            //         'access_token' => 'токен',
            //         'v' => '5.85',
            //         'attachments'=>'photo'.'66748_265827614'.'http://habrahabr.ru'
            //     ]
            // ]);
            // $response = curl_exec($curl);
            // if ($response === false) {
            //     die('Во время запроса произошла ошибка!'.PHP_EOL.curl_errno($curl).' - '.curl_error($curl));
            // }
            
            // $response = json_decode($response, true);
            // if (isset($response['error'])) {
            //     die('Ошибка VK API!'.PHP_EOL.$response['error']['error_code'].' - '.$response['error']['error_msg']);
            // }
            // curl_close($curl);
            
            // $response = $response['response'];
            // var_dump($response);
?>
  • Вопрос задан
  • 48 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы