Skip to content

Instantly share code, notes, and snippets.

@acmi
Last active December 17, 2015 16:59
Show Gist options
  • Select an option

  • Save acmi/5642513 to your computer and use it in GitHub Desktop.

Select an option

Save acmi/5642513 to your computer and use it in GitHub Desktop.
Wall example
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