A
A
AlexKrsk2017-09-28 19:32:48
Java
AlexKrsk, 2017-09-28 19:32:48

How to upload a photo via VK API to Java desktop application?

Hello.
I've searched through a bunch of things and there is no sensible answer. How to upload a photo to the server using photos.getUploadServer and then save it to your group's album?
There is a piece of code. Variables ACCESS_TOKEN, USER_ID, ALBOM_ID, GROUP_ID of type int are defined at the beginning of the code by my data.

TransportClient transportClient = HttpTransportClient.getInstance();
        VkApiClient vk = new VkApiClient(transportClient);
        UserActor actor = new UserActor(USER_ID, ACCESS_TOKEN);
        Response response = vk.photos().getUploadServer(actor).albumId(ALBOM_ID).groupId(GROUP_ID).execute();

Error -Error:(115, 108) Gradle: error: incompatible types: PhotoUpload cannot be converted to Response
what type is this PhotoUpload ?? maybe I'm not trying to call this method correctly at all?
and at the very end it is also not clear how to work with
vk.photos().saveWallPhoto(UserActor actor, String photo);

the actor is clear what to specify, but what else is the string as the second parameter ??
in the VK API documentation there are no examples with code at all, especially in java ...
can someone suggest or give an example of a complete code for working with these methods?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
polk1lo, 2017-10-05
@polk1lo

Look closely at what type your last .execute method returns.
It returns PhotoUpload, and you are trying to cast it in Response

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question