Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yshrsmz/twitter4kt
Twitter API client for KotlIn Multiplatform
https://github.com/yshrsmz/twitter4kt
hacktoberfest kotlin-multiplatform twitter-api
Last synced: 3 months ago
JSON representation
Twitter API client for KotlIn Multiplatform
- Host: GitHub
- URL: https://github.com/yshrsmz/twitter4kt
- Owner: yshrsmz
- License: apache-2.0
- Created: 2020-08-13T02:26:55.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-17T15:57:41.000Z (almost 4 years ago)
- Last Synced: 2024-05-02T01:30:57.368Z (9 months ago)
- Topics: hacktoberfest, kotlin-multiplatform, twitter-api
- Language: Kotlin
- Homepage:
- Size: 286 KB
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOGS.md
- License: LICENSE
Awesome Lists containing this project
README
twitter4kt
===Twitter API client for Kotlin Multiplatform Project.
Currently, only available for jvm.
## Setup
### For build.gradle.kts
LATEST_VERSION: `0.2.3`
Twitter4kt is distributed via Maven Central```kotlin
plugins {
id("org.jetbrains.kotlin.multiplatform") version "1.4.10"
}repositories {
mavenCentral()
jcenter()
maven(url = "https://kotlin.bintray.com/kotlinx/") // needed for kotlinx-datetime
}kotlin {
jvm()sourceSets {
val commonMain by getting {
implementation("com.codingfeline.twitter4kt:core-api:$LATEST_VERSION")
implementation("com.codingfeline.twitter4kt:v1-api:$LATEST_VERSION")// if you need logging for HTTP calls
implementatin("io.ktor:ktor-client-logging:$KTOR_VERSION")
}
}
}
```## Usage
```kotlin
val twitter = Twitter {
consumerKeys = ConsumerKeys(
key = "",
secret = ""
)
httpClientConfig = {
install(Logging) {
logger = Logger.SIMPLE
level = LogLevel.ALL
}
}
}val authFlow = twitter.launchOAuthFlow()
launch(Dispatchers.io) {
val requestToken: RequestToken = authFlow.fetchRequestToken()val url = requestToken.authorizationUrl
val pinCode = ""val accessToken = authFlow.fetchAccessToken(requestToken, pinCode)
authFlow.destroy()
val client = twitter.startSession(accessToken)
val result: ApiResult = client.statuses.update(status = "Hello from twitter4kt!")
}
```## Development
Create `./secrets.properties`
```properties
twitter_consumer_key=
twitter_consumer_secret=
twitter_access_token=
twitter_access_token_secret=
twitter_user_id=
twitter_screen_name=
```We use these values for testing