Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I upload image files to the community wall and to my wall correctly? #516

Open
surgutandrey opened this issue Nov 13, 2024 · 1 comment

Comments

@surgutandrey
Copy link

How do I upload image files to the community wall and to my wall correctly? Please help me! I've tried different methods, I can't figure it out!

Окружение

vk_api: 11.9.9

Пример

vk_session = vk_api.VkApi(token=config.vk_token)
            vk = vk_session.get_api()
            upload = VkUpload(vk_session)

            attachments = []

            if photos:
                for idx, image in enumerate(photos):
                    image.seek(0)
                    photo = upload.photo_wall(photos=image, user_id = 4395736, group_id=group_id)
                    print(photo)
                    attachments.append(f"https://vk.com/photo-{photo[0]['owner_id']}_{photo[0]['id']}")

            post_params = {
                'owner_id': f"-{group_id}",
                'message': text,
                'attachments': ','.join(attachments) if attachments else None
            }

            response = vk.wall.post(**post_params)
@surgutandrey
Copy link
Author

Как правильно загрузить файлы изображений на стену сообщества и на свою стену? ПРошу помощи! Перепробовал разные методы, не получается разобраться!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant