L
L
Leks22018-12-20 16:44:33
Java
Leks2, 2018-12-20 16:44:33

Send a photo to the wall of the VK group?

I can’t upload a photo to the wall in the group, I uploaded a photo to the photo3420_326050355 profile and received the url when passing VKApi.wall().post no photo, text message is

VKRequest request = VKApi.users().get(VKParameters.from(VKApiConst.FIELDS, FIELDS));
                    request.executeWithListener(new VKRequest.VKRequestListener() {
                        @Override
                        public void onComplete(VKResponse response) {
                            VKApiUser user = ((VKList<VKApiUser>) response.parsedModel).get(0);

                            String   urlImage = user.photo_max;
                            VKApiPhoto  photo = new VKApiPhoto();
                            attachments = new VKAttachments();



                            photo.photo_604  = urlImage;
                            attachments.add(photo);
                            Log.i("VK",  " "+urlImage);


                        }

                    });
VKParameters.from(VKApiConst.OWNER_ID, -546456,
                       VKApiConst.ATTACHMENTS,  attachments,
                        VKApiConst.MESSAGE, message);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav Onishchenko, 2018-12-20
@STFBEE

The VKSDK readme contains an example of uploading a photo to a user's wall:

PhotoUpload serverResponse = vk.photos().getWallUploadServer(actor).execute();
WallUploadResponse uploadResponse = vk.upload().photoWall(serverResponse.getUploadUrl(), file).execute();
List<Photo> photoList = vk.photos().saveWallPhoto(actor, uploadResponse.getPhoto())
     .server(uploadResponse.getServer())
     .hash(uploadResponse.getHash())
     .execute();

Photo photo = photoList.get(0); 
String attachId = "photo" + photo.getOwnerId() + "_" + photo.getId();
GetResponse getResponse = vk.wall().post(actor)
    .attachments(attachId)
    .execute();

If you need to publish on the wall of another user, then in the last execution add a method call about "owner_id"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question