lib/mambanation/base.rb in mambanation-0.1.26 vs lib/mambanation/base.rb in mambanation-0.1.27
- old
+ new
@@ -150,30 +150,17 @@
def posts(id, query = {})
perform_get("/posts/#{id}.json", :query => query)
end
# options:
- # application_id Integer,
- # posts Array, Hash, String
+ # application_id => Integer, Array
def user_posts(id, query = {})
- query[:posts] = CGI.escape(urlencode_array({:posts => query[:posts]})) if query.is_a?(Hash) && query[:posts]
+ query[:application_id] = urlencode_array({:application_id => query[:application_id]}) if query.is_a?(Hash) && query[:application_id]
perform_get("/users/#{id.to_i}/posts.json", :query => query)
end
- def urlencode_array(value_hash)
- return_string = ''
- value_hash.each_pair do |k,v|
- return_string = case v.class.to_s
- when "Hash" then urlencode_array(v)
- when "Array" then v.map { |value| value.is_a?(Hash) ? urlencode_array(value) : "#{k}[]=#{value}" }.join('&')
- else "#{k}[]=#{v}"
- end
- end
- return_string
- end
-
def create_post(id, post, application_id, query = {})
perform_post("/posts", :body => { :user_id => id, :post => post, :application_id => application_id }.merge(query))
end
def publish_post(id, stream_id, query = {})
@@ -251,9 +238,21 @@
end
def build_multipart_bodies(parts) self.class.build_multipart_bodies(parts) end
private
+
+ def urlencode_array(value_hash)
+ return_string = ''
+ value_hash.each_pair do |k,v|
+ return_string = case v.class.to_s
+ when "Hash" then urlencode_array(v)
+ when "Array" then v.map { |value| value.is_a?(Hash) ? urlencode_array(value) : "#{k}[]=#{value}" }.join('&')
+ else "#{k}[]=#{v}"
+ end
+ end
+ return_string
+ end
def request_options(opts={})
opts[:headers] ||= {}
opts[:headers].merge! "X-FB-COOKIES" => @fbs_cookies if @fbs_cookies
opts