facebook-cli 1.3.10 → 1.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fbcli.rb +32 -3
  3. data/lib/fbcli/facebook.rb +30 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffc1817a8e17e02b98a671538b6c6363baa6c5c8
4
- data.tar.gz: 18e71a389f418d64a5c4f766d1e29c428adc4ad4
3
+ metadata.gz: dc3326a497849e36db34d832e9c0580a48026d74
4
+ data.tar.gz: 64e2129fcc6ca4eaf75600ef59933d49d764b6fb
5
5
  SHA512:
6
- metadata.gz: b2cc32f474b9199bdc15f6757b6e2b7020df41e5e53fc46b63cf864ba3c04983e03be588f069343a8f0366672b4e74cf8516071f30510bca156098ee9398f1e7
7
- data.tar.gz: 27f266d8b9b811d2cef265cdc896edc867272039e7c639818cf6aa4c47a4a1705f1a9e803ae5a6f2e05e425b5d3407e72a2c127cc2178ead81bff62df1cc8556
6
+ metadata.gz: 74ca6c74ac23d433d5476a7a24b3b8f70ae041f51853a6eb5c9a1d9644fbbe28a9a52529f9467e17980fb3d6fc172db680658c67cec567addd679a774451a6c3
7
+ data.tar.gz: cd6d07435b08a12e2e355f22d33249ba676069d26c6b1b8b7ca42b3419de542a5af9cb3fba19739551ec9402d662213cdbbfd5b3cbddf41d85776777ea225753
data/lib/fbcli.rb CHANGED
@@ -10,7 +10,7 @@ include GLI::App
10
10
 
11
11
  program_desc "Facebook command line interface"
12
12
 
13
- version '1.3.10'
13
+ version '1.3.12'
14
14
 
15
15
  flag [:token], :desc => 'Provide Facebook access token', :required => false
16
16
  flag [:pages, :p], :desc => 'Max pages', :required => false, :default_value => -1
@@ -117,11 +117,40 @@ command :me do |c|
117
117
  end
118
118
  end
119
119
 
120
- desc "Post to your timeline"
120
+ desc "Post a message or image to your timeline"
121
121
  arg_name "message"
122
122
  command :post do |c|
123
+ c.flag [:i, :image], :desc => 'File or URL of image to post'
123
124
  c.action do |global_options,options,args|
124
- profile_id, post_id = FBCLI::write_post global_options, args[0]
125
+ if options['image'].nil?
126
+ profile_id, post_id = FBCLI::publish_post global_options, args[0]
127
+ else
128
+ profile_id, post_id = FBCLI::publish_photo global_options, args[0], options['image']
129
+ end
130
+
131
+ puts "Your post: #{link_to_post profile_id, post_id}"
132
+ end
133
+ end
134
+
135
+ desc "Post a link to your timeline"
136
+ arg_name "url"
137
+ command :postlink do |c|
138
+ c.flag [:m, :message], :desc => 'Main message'
139
+ c.flag [:n, :name], :desc => 'Link name'
140
+ c.flag [:d, :description], :desc => 'Link description'
141
+ c.flag [:c, :caption], :desc => 'Link caption'
142
+ c.flag [:i, :image], :desc => 'Link image'
143
+ c.action do |global_options,options,args|
144
+ link_metadata = {
145
+ "name" => options['name'],
146
+ "link" => args[0],
147
+ "caption" => options['caption'],
148
+ "description" => options['description'],
149
+ "picture" => options['image']
150
+ }
151
+
152
+ profile_id, post_id = FBCLI::publish_link global_options, options['message'], link_metadata
153
+
125
154
  puts "Your post: #{link_to_post profile_id, post_id}"
126
155
  end
127
156
  end
@@ -79,7 +79,7 @@ module FBCLI
79
79
  end
80
80
  end
81
81
 
82
- def self.write_post(global_options, msg)
82
+ def self.publish_post(global_options, msg)
83
83
  if @@api.nil?
84
84
  @@api = init_api(global_options)
85
85
  end
@@ -92,4 +92,33 @@ module FBCLI
92
92
 
93
93
  [profile_id, post_id]
94
94
  end
95
+
96
+ def self.publish_link(global_options, msg, link_metadata)
97
+ if @@api.nil?
98
+ @@api = init_api(global_options)
99
+ end
100
+
101
+ begin
102
+ profile_id, post_id = @@api.put_wall_post(msg, link_metadata)['id'].split '_', 2
103
+ rescue Koala::Facebook::APIError => e
104
+ exit_now! koala_error_str e
105
+ end
106
+
107
+ [profile_id, post_id]
108
+ end
109
+
110
+ def self.publish_photo(global_options, msg, image_file_or_url)
111
+ if @@api.nil?
112
+ @@api = init_api(global_options)
113
+ end
114
+
115
+ begin
116
+ result = @@api.put_picture(image_file_or_url, {:message => msg})
117
+ profile_id, post_id = result['post_id'].split '_', 2
118
+ rescue Koala::Facebook::APIError => e
119
+ exit_now! koala_error_str e
120
+ end
121
+
122
+ [profile_id, post_id]
123
+ end
95
124
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebook-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.10
4
+ version: 1.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ildar Sagdejev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-28 00:00:00.000000000 Z
11
+ date: 2016-09-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A limited command line interface to Facebook
14
14
  email: specious@gmail.com