Top Level Namespace

Includes:
GLI::App

Defined Under Namespace

Modules: FBCLI

Constant Summary collapse

APP_NAME =
File.basename($0, File.extname($0))
CONFIG_FILE =
File.join(ENV['HOME'], ".#{APP_NAME}rc")
SETUP_INSTRUCTIONS =

Update instructions in README.md when these change

"You must create and configure a Facebook application to interact with the Graph API.\n\n- Create a new application at: https://developers.facebook.com/apps\n- Under \"PRODUCTS\" in the left sidebar:\n  - Click \"+ Add Product\"\n  - Choose \"Facebook Login\" by clicking its \"Set Up\" button\n  - Don't bother choosing a platform, instead click \"Settings\" under \"Facebook Login\" in the side bar\n  - Under \"Client OAuth Settings\", switch \"Use Strict Mode for Redirect URIs\" to \"No\"\n  - Under \"Valid OAuth redirect URIs\", add: \"http://localhost:3333/\"\n      (or your host identifier and port number, to receive auth code during authentication)\n  - Click \"Save Changes\"\n- In the \"App Review\" tab:\n  - Flip the switch to make your app live\n  - Choose a category (any one will do)\n  - Click \"Confirm\"\n- In the \"Dashboard\" tab:\n  - Click \"Show\" to reveal your app secret\n  - Save the App ID and App Secret by running:\n\n    \#{APP_NAME} config --appid=<app-id> --appsecret=<app-secret>\n\nObtain an access token by running:\n\n    \#{APP_NAME} login\n\nIf authenticating on a remote machine or using a different port to receive the auth code:\n\n    \#{APP_NAME} login --host <hostname-or-ip> --port <port>\n"

Instance Method Summary collapse

Instance Method Details

#date_str(date) ⇒ Object

Facebook returns dates in ISO 8601 or unix timestamp format



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

def date_str(date)
  t = (date.is_a? Integer) ? Time.at(date) : Time.parse(date).localtime

  # Convert to human friendly representation in user's time zone (almost RFC 2822)
  t.strftime('%a, %-d %b %Y %H:%M:%S %Z')
end


21
22
23
# File 'lib/fbcli.rb', line 21

def link(path)
  "https://www.facebook.com/#{path}"
end

#link_to_post(full_post_id) ⇒ Object



25
26
27
28
# File 'lib/fbcli.rb', line 25

def link_to_post(full_post_id)
  profile_id, post_id = full_post_id.split '_', 2
  link "#{profile_id}/posts/#{post_id}"
end

#save_configObject



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

def save_config
  File.open(CONFIG_FILE, 'w') do |f|
    f.write $config.to_yaml
  end
end