Methods used to interact with Facebook’s legacy REST API. Where possible, you should use the newer, faster Graph API to interact with Facebook; in the future, the REST API will be deprecated. For now, though, there are a few methods that can’t be done through the Graph API.
When using the REST API, Koala will use Facebook’s faster read-only servers whenever the call allows.
See github.com/arsduo/koala/wiki/REST-API for a general introduction to Koala and the Rest API.
@private read-only methods for which we can use API-read taken directly from the FB PHP library (github.com/facebook/php-sdk/blob/master/src/facebook.php)
Make a call to the REST API.
@note The order of the last two arguments is non-standard (for historical reasons). Sorry.
@param fb_method the API call you want to make @param args (see Koala::Facebook::GraphAPIMethods#graph_call) @param options (see Koala::Facebook::GraphAPIMethods#graph_call) @param verb (see Koala::Facebook::GraphAPIMethods#graph_call)
@raise [Koala::Facebook::APIError] if Facebook returns an error
@return the result from Facebook
# File lib/koala/api/rest_api.rb, line 38 def rest_call(fb_method, args = {}, options = {}, verb = "get") Koala::Utils.deprecate("The REST API is now deprecated; please use the equivalent Graph API methods instead. See http://developers.facebook.com/blog/post/616/.") options = options.merge!(:rest_api => true, :read_only => READ_ONLY_METHODS.include?(fb_method.to_s)) api("method/#{fb_method}", args.merge('format' => 'json'), verb, options) do |response| # check for REST API-specific errors if response.status >= 400 begin response_hash = JSON.load(response.body) rescue JSON::ParserError response_hash = {} end error_info = { 'code' => response_hash['error_code'], 'error_subcode' => response_hash['error_subcode'], 'message' => response_hash['error_msg'] } if response.status >= 500 raise ServerError.new(response.status, response.body, error_info) else raise ClientError.new(response.status, response.body, error_info) end end end end
Set a Facebook application’s properties.
@param properties a hash of properties you want to update with their new values. @param (see rest_call) @param options (see rest_call)
@return true if successful, false if not. (This call currently doesn’t give useful feedback on failure.)
# File lib/koala/api/rest_api.rb, line 21 def set_app_properties(properties, args = {}, options = {}) raise AuthenticationError.new(nil, nil, "setAppProperties requires an access token") unless @access_token rest_call("admin.setAppProperties", args.merge(:properties => JSON.dump(properties)), options, "post") end