Closed mohsen2986 closed 3 years ago
Can you provide some logs and your modification? And how you're calling this function?
ofcourse ... i clone hole repository for contribute , i think this is really great project
in your sample directory sampels/follow/followUserFollowers i just replace the user value with some id like this val user = "my_id"
but i get this
Exception in thread "main" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String at bot.InstagramBot.getUserIdByName(InstagramBot.kt:425) at bot.InstagramBot.convertToUserId(InstagramBot.kt:446) at bot.InstagramBot.getUserFollowers(InstagramBot.kt:556) at bot.InstagramBot.getUserFollowers$default(InstagramBot.kt:551) at bot.InstagramBot.followUserFollowers(InstagramBot.kt:1621) at bot.InstagramBot.followUserFollowers$default(InstagramBot.kt:1619) at samples.follow.FollowUsersFollowersKt$main$1.invokeSuspend(FollowUsersFollowers.kt:22) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56) at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:271) at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:79) at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:54) at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source) at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:36) at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source) at samples.follow.FollowUsersFollowersKt.main(FollowUsersFollowers.kt:10) at samples.follow.FollowUsersFollowersKt.main(FollowUsersFollowers.kt)
You need to use your username in that function, not (numeric) user id. Try with username and let me know the result.
i just do this , here is my code `@ExperimentalCoroutinesApi fun main() = runBlocking {
val username = Credentials.USERNAME
val password = Credentials.PASSWORD
val bot = InstagramBot()
bot.prepare(username)
bot.login(username, password)
val user = "@mohsen_alak"
val howManyFollowersYouWantToFollow = 10
bot.followUserFollowers(user, howManyFollowersYouWantToFollow).collect { println(it) }
}` note) now the account is disabled
the log is belongs to convertToUserId() function in 439th line of InstagramBot class
This was due to bug in case of user is not found on instagram. I've fixed it. Please check now.
i still face the same log .
the function value.toLongOrNull()
in convertToUserId throw these .
i put valid and available username , but get the same log end errors.
can u explain why use value.toLongOrNull()
?
i replace that with correct function but still not work!
You need to clone the updated repository as i've fixed the issue. It no more throw that error.
value.toLongOrNull()
is there to parse userId if userId is given in place of username.
I've fixed another bug that was causing issue in getUserIdByName()
method. Please check now.
first issue that i archived is can not convert long to string in get_id function ! and when i fix it still have no response from API!!! it actually still work?