lib/koala/graph_api.rb in koala-1.2.1 vs lib/koala/graph_api.rb in koala-1.3.0rc1
- old
+ new
@@ -174,22 +174,41 @@
args.merge!({:q => search_terms}) unless search_terms.nil?
graph_call("search", args, "get", options)
end
# Convenience Methods
+ #
+ # in general, we're trying to avoid adding convenience methods to Koala
+ # except to support cases where the Facebook API requires non-standard input
+ # such as JSON-encoding arguments, posts directly to objects, etc.
+
+ def fql_query(query, args = {}, options = {})
+ get_object("fql", args.merge(:q => query), options)
+ end
- def get_page_access_token(object_id)
- result = get_object(object_id, :fields => "access_token") do
+ def fql_multiquery(queries = {}, args = {}, options = {})
+ if results = get_object("fql", args.merge(:q => MultiJson.encode(queries)), options)
+ # simplify the multiquery result format
+ results.inject({}) {|outcome, data| outcome[data["name"]] = data["fql_result_set"]; outcome}
+ end
+ end
+
+ def get_page_access_token(object_id, args = {}, options = {})
+ result = get_object(object_id, args.merge(:fields => "access_token"), options) do
result ? result["access_token"] : nil
end
end
def get_comments_for_urls(urls = [], args = {}, options = {})
# Fetchs the comments for given URLs (array or comma-separated string)
# see https://developers.facebook.com/blog/post/490
return [] if urls.empty?
args.merge!(:ids => urls.respond_to?(:join) ? urls.join(",") : urls)
get_object("comments", args, options)
+ end
+
+ def set_app_restrictions(app_id, restrictions_hash, args = {}, options = {})
+ graph_call(app_id, args.merge(:restrictions => MultiJson.encode(restrictions_hash)), "post", options)
end
# GraphCollection support
def get_page(params)
# Pages through a set of results stored in a GraphCollection