在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):vksdk/vk-sdk-kotlin开源软件地址(OpenSource Url):https://github.com/vksdk/vk-sdk-kotlin开源编程语言(OpenSource Language):Kotlin 98.4%开源软件介绍(OpenSource Introduction):VK SDK KotlinCreate a chat-bot for VK.com in a few lines of code, use the API and forget about the limitations Unofficial VK.com SDK, written in Kotlin. Based on Kotlin Multiplatform project, but has Java-friendly API. See the documentation: https://vksdk.github.io/vk-sdk-kotlin For Kotlin 1.3.72 use version 0.0.5 and below. Minimal example of the echo-chatbotKotlin// From here: https://vk.com/club151083290 take the ID
val groupId = 151083290
// Read more: https://vk.com/dev/access_token
val accessToken = "abcdef123456..."
// There are two http clients available for now:
// JVM-only OkHttp-based
// and common ktor-based
val vkHttpClient = VkOkHttpClient()
val client = VkApiClient(groupId, accessToken, VkApiClient.Type.Community, VkSettings(vkHttpClient))
client.onMessage { messageEvent ->
client.sendMessage {
peerId = messageEvent.message.peerId
message = "Hello, World!"
// You can use stickers, replies, location, etc.
// All of the message parameters are supported.
}.execute()
}
client.startLongPolling() Javaint groupId = 151083290;
String accessToken = "abcdef123456...";
HttpClient vkHttpClient = new VkOkHttpClient();
VkApiClient client = new VkApiClient(groupId, accessToken, VkApiClient.Type.Community, new VkSettings(vkHttpClient));
client.onMessage(event -> {
new Message()
.peerId(event.getMessage().getPeerId())
.text("Hello, world!")
.sendFrom(client)
.execute();
});
client.startLongPolling(); FeaturesThe primary goal of the library is to cover most of the possible needs but in an abstract way. You can't find here a hundred of pre-defined data classes for each API method, but you can write the highly customizable solution in most convenient way.
InstallLibrary is uploaded to the Maven Central Repository. For Gradle 6.0+ or with metadata enabled, add the dependencies in this way: // core module is required
implementation "com.petersamokhin.vksdk:core:$vkSdkVersion"
// One of the HTTP clients is also required.
// You can use pre-defined OkHttp-based client, but only for JVM.
implementation "com.petersamokhin.vksdk:http-client-jvm-okhttp:$vkSdkVersion"
// Or else you can use the common HTTP client, which is based on ktor
// and available for all of the platforms, including JVM.
// In this case, you also must specify the ktor engine.
implementation "com.petersamokhin.vksdk:http-client-common-ktor:$vkSdkVersion" Otherwise, add implementation "com.petersamokhin.vksdk:core-jvm:$vkSdkVersion"
implementation "com.petersamokhin.vksdk:http-client-common-ktor-jvm:$vkSdkVersion"
// and OkHttp-based client is already JVM-only
implementation "com.petersamokhin.vksdk:http-client-jvm-okhttp:$vkSdkVersion" LimitationsUnsupported platforms
Unsupported functionality
3rd party
LicenseSee the License |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论