Class: PigeonFu::Authenticate
- Inherits:
-
Object
- Object
- PigeonFu::Authenticate
- Defined in:
- lib/pigeon_fu/authenticate.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(with_interface_code) ⇒ Authenticate
constructor
调用相关API之前需要获得电信开放平台的认证授权.
- #run ⇒ Object
Constructor Details
#initialize(with_interface_code) ⇒ Authenticate
调用相关API之前需要获得电信开放平台的认证授权
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pigeon_fu/authenticate.rb', line 9 def initialize(with_interface_code) raise RuntimeError, "constant PIGEON_ACCOUNT_SID sould be defined" unless defined?(ENV["PIGEON_ACCOUNT_SID"]) raise RuntimeError, "constant PIGEON_ACCOUNT_TOKEN sould be defined" unless defined?(ENV["PIGEON_ACCOUNT_TOKEN"]) @result = Hash.new @options = Hash.new @options[:account_sid] = ENV["PIGEON_ACCOUNT_SID"] # 开发者的用户ID @options[:account_token] = ENV["PIGEON_ACCOUNT_TOKEN"] # 开发者访问电信API的密钥 @options[:api_id] ||= with_interface_code # API功能接口的编号(电信为每种API定义了一个数字编号,比如发短信的接口ID为10000033) @options[:url] ||= PigeonFu::AUTH_INTERFACE_URL @options[:timestamp] = (Time.now.to_f * 1000).to_i @options[:session_id] = session_id end |
Class Method Details
.start(options = {}) ⇒ Object
4 5 6 |
# File 'lib/pigeon_fu/authenticate.rb', line 4 def self.start(={}) new().run end |
Instance Method Details
#run ⇒ Object
22 23 24 |
# File 'lib/pigeon_fu/authenticate.rb', line 22 def run parse_result(make_request) end |