Module: ThreadsClientRuby

Defined in:
lib/threads_client_ruby.rb,
lib/threads_client_ruby/version.rb

Defined Under Namespace

Modules: Config Classes: Core, Error

Constant Summary collapse

DEFAULT_DEVICE_ID =
"android-#{rand(36**24).to_s(36)}"
LATEST_ANDROID_APP_VERSION =
'289.0.0.77.109'
BASE_API_URL =
'https://i.instagram.com/api/v1'
LOGIN_URL =
BASE_API_URL + '/bloks/apps/com.bloks.www.bloks.caa.login.async.send_login_request/'
POST_URL =
BASE_API_URL + '/media/configure_text_only_post/'
POST_WITH_IMAGE_URL =
BASE_API_URL + '/media/configure_text_post_app_feed/'
DEFAULT_LSD_TOKEN =
'NjppQDEgONsU_1LCzrmp6q'
VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.config(&block) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/threads_client_ruby.rb', line 30

def self.config(&block)
  if block_given?
    block.call(ThreadsClientRuby::Config)
  else
    ThreadsClientRuby::Config
  end
end

.get_post_id_from_url(post_url, options = {}) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/threads_client_ruby.rb', line 53

def self.get_post_id_from_url(post_url, options = {})
uri = URI.parse(post_url)
response = Net::HTTP.get_response(uri)
text = response.body.to_s.gsub(/\s+/, '').gsub(/\n+/, '')

post_id = text.match(/{"post_id":"(.*?)"}/)&.captures&.first
lsd_token = text.match(/"LSD",\[\],{"token":"(\w+)"},\d+\]/)&.captures&.first
post_id
end

.get_userinfoObject



38
39
40
41
# File 'lib/threads_client_ruby.rb', line 38

def self.get_userinfo
  core = ThreadsClientRuby::Core.new ThreadsClientRuby::Config.credentials
  core.
end

.publish(options = {}) ⇒ Object

available key for options:

  • text

  • image

  • url

  • reply_id



48
49
50
51
# File 'lib/threads_client_ruby.rb', line 48

def self.publish(options = {})
  core = ThreadsClientRuby::Core.new ThreadsClientRuby::Config.credentials
  core.publish(options)
end