yukihirai0505 / iservice   2.4.1

MIT License GitHub

:laughing: do instagram actions programmatically

Scala versions: 2.11

To get instagram all followers.



If you don't have it already, make sure you add the Maven Central as resolver in your SBT settings:

You need to include the library as your dependency:

libraryDependencies += "com.yukihirai0505" % "iservice_2.11" % "2.0.0"



Using browser url

Using scala

import java.io.File

import com.yukihirai0505.iService.IService

import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global

val (username, password) = (sys.env("INSTAGRAM_USERNAME"), sys.env("INSTAGRAM_PASSWORD"))
val iService = new IService(username, password)

// Get followers
iService.getFollowers(targetAccountName = "[target account name]").flatMap {
  case Right(result) => Future successful result.foreach(n => println(n.node.username))
  case Left(_) => Future successful "failed"

// Get hash tag search result
iService.getSearchHashTagResult(hashTag = "[hash tag]").flatMap {
  case Right(v) => Future successful v.media.nodes.foreach(println)
  case Left(e) => Future successful "failed"

// Like to media
iService.likeMedia(mediaId = "[media id]", "[shortcode]").flatMap {
  case Right(v) => Future successful println(v.status)
  case Left(e) => Future successful println("failed", e)

// Post to timeline
iService.postNaturalWays(new File("path/to/post"), "test").flatMap {
  case Right(v) => Future successful println(s"result:${v.status} code: ${v.code}")
  case Left(e) => Future successful println("failed", e)