Last active
December 17, 2015 16:59
-
-
Save acmi/5642513 to your computer and use it in GitHub Desktop.
Wall example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.vk.api.other.OtherCommon | |
| import com.vk.api.wall.Post | |
| import com.vk.api.wall.WallCommon | |
| import com.vk.worker.impl.VKWorkerGroup | |
| class WallTest { | |
| static main(args) { | |
| def tokens = [ | |
| 'TOKEN1', | |
| 'TOKEN2' | |
| ].toArray(new String[0]) | |
| def wall = 'WALL_ID_OR_SCREEN_NAME' | |
| def vkapi = new VKWorkerGroup(tokens) | |
| vkapi.cacheableMethods.add('users.get') | |
| vkapi.cacheableMethods.add('groups.getById') | |
| use(OtherCommon, WallCommon) { | |
| def wallInfo = vkapi.getInfo(wall) | |
| if (wallInfo == null) { | |
| println 'wall not found' | |
| } else { | |
| vkapi.get(wallInfo.id).each { Post post -> | |
| println "${post.getFromInfo(vkapi)}->${post.getToInfo(vkapi)}(${post.date}): ${post.text}" | |
| post.getComments(vkapi).each { comment -> | |
| println "\t${comment.getFromInfo(vkapi)}(${comment.date}): ${comment.text}" | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment