facebook-cli 1.4.13 → 1.4.15

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9170abefa09224d7195909f1f59d159e855d7ce0
4
- data.tar.gz: c8afbfa53366fc1121e9867bd26f2dda9461a5c1
3
+ metadata.gz: b8b27d241e4fc8f53ea0148f5506ab4c7548d7f0
4
+ data.tar.gz: 15249f89d1a9feed9ba6e4c14c70fb1742c926f6
5
5
  SHA512:
6
- metadata.gz: bbcb7542e5badc17ac9c7d1a4871d055542c3b184f53d7a624e0b0bf68a524ac566bd68f0b36b851540cc74a06023d1f99513a54d27706652307ec4dc44ead9f
7
- data.tar.gz: 8909e2f324579e2baa5c30850b5d6b6cdad69ae1e1c8e6bde2da128c008ce7f557c6003c6accb6ed011cde9c5c9c15a38fa2965888ad3b3b63a18601575f9651
6
+ metadata.gz: 835ef2849eb37b4c4c5869bbc31248be910ccf812d30000887defd9d9f98256378dbedf39d12d6311636756cd58f254a3d5d1716f127aff348a6d6ac5a4fe824
7
+ data.tar.gz: 95c1dea98a1e7811c55f2dcdfd6f6673aead703a233fdb0654cdb28c7c0bbdd815bf1a826a538963fd2aa974533f50867f6297c40e24a132387dcdc01aca609d
data/lib/fbcli.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'gli'
2
2
  require 'yaml'
3
+ require 'json'
3
4
  require 'fbcli/auth'
4
5
  require 'fbcli/version'
5
6
  require 'fbcli/facebook'
@@ -148,12 +149,38 @@ command :logout do |c|
148
149
  end
149
150
  end
150
151
 
151
- desc "Show your name and profile ID"
152
+ desc "Make a Facebook API request"
153
+ arg_name "request"
154
+ long_desc %(
155
+ This is similar to the online tool:
156
+
157
+ https://developers.facebook.com/tools/explorer
158
+
159
+ For example, try:
160
+
161
+ #{APP_NAME} api "165795193558366?fields=name,about,website"
162
+
163
+ To view the list of valid fields you can request, ask for the metadata:
164
+
165
+ #{APP_NAME} api "165795193558366?metadata=1"
166
+
167
+ Some valid requests may not be honored due to insufficient permissions, which were established during the authentication process.
168
+ )
169
+ command :api do |c|
170
+ c.switch [:raw], :desc => 'Output unformatted JSON', :negatable => false
171
+ c.action do |global_options, options, args|
172
+ res = FBCLI::raw_request args[0]
173
+ res = JSON.pretty_generate res unless options['raw']
174
+ puts res
175
+ end
176
+ end
177
+
178
+ desc "Show your profile information"
152
179
  command :me do |c|
153
180
  c.action do
154
181
  FBCLI::request_object "me" do |data|
155
- puts "Name: #{data["name"]}"
156
- puts "ID: #{data["id"]}"
182
+ puts "Name: #{data["name"]} (#{data["id"]})"
183
+ puts "Picture: http://graph.facebook.com/#{data["id"]}/picture?type=large"
157
184
  end
158
185
  end
159
186
  end
@@ -32,8 +32,16 @@ module FBCLI
32
32
  end
33
33
  end
34
34
 
35
+ def self.raw_request(req)
36
+ api_call lambda { |api|
37
+ api.graph_call req
38
+ }
39
+ end
40
+
35
41
  def self.logout
36
- api_call lambda { |api| api.delete_object("me/permissions") }
42
+ api_call lambda { |api|
43
+ api.delete_object("me/permissions")
44
+ }
37
45
  end
38
46
 
39
47
  def self.request_token_info
@@ -83,17 +91,26 @@ module FBCLI
83
91
  end
84
92
 
85
93
  def self.publish_post(msg, link_metadata = {})
86
- result = api_call lambda { |api| api.put_wall_post(msg, link_metadata) }
94
+ result = api_call lambda { |api|
95
+ api.put_wall_post(msg, link_metadata)
96
+ }
97
+
87
98
  result['id']
88
99
  end
89
100
 
90
101
  def self.publish_image(msg, image_file_or_url)
91
- result = api_call lambda { |api| api.put_picture(image_file_or_url, {:message => msg}) }
102
+ result = api_call lambda { |api|
103
+ api.put_picture(image_file_or_url, {:message => msg})
104
+ }
105
+
92
106
  result['post_id']
93
107
  end
94
108
 
95
109
  def self.publish_video(msg, video_file_or_url, title = nil)
96
- result = api_call lambda { |api| api.put_video(video_file_or_url, {:title => title, :description => msg}) }
110
+ result = api_call lambda { |api|
111
+ api.put_video(video_file_or_url, {:title => title, :description => msg})
112
+ }
113
+
97
114
  result['id']
98
115
  end
99
116
  end
data/lib/fbcli/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module FBCLI
2
- VERSION = '1.4.13'
2
+ VERSION = '1.4.15'
3
3
  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.4.13
4
+ version: 1.4.15
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-12-02 00:00:00.000000000 Z
11
+ date: 2017-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: koala