Module: Koala::Facebook::RestAPIMethods
- Included in:
- API
- Defined in:
- lib/koala/api/rest_api.rb
Overview
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.
Instance Method Summary collapse
-
#rest_call(fb_method, args = {}, options = {}, verb = "get") ⇒ Object
Make a call to the REST API.
-
#set_app_properties(properties, args = {}, options = {}) ⇒ Object
Set a Facebook application’s properties.
Instance Method Details
#rest_call(fb_method, args = {}, options = {}, verb = "get") ⇒ Object
Note:
The order of the last two arguments is non-standard (for historical reasons). Sorry.
Make a call to the REST API.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/koala/api/rest_api.rb', line 38 def rest_call(fb_method, args = {}, = {}, 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/.") = .merge!(:rest_api => true, :read_only => READ_ONLY_METHODS.include?(fb_method.to_s)) api("method/#{fb_method}", args.merge('format' => 'json'), verb, ) do |response| # check for REST API-specific errors if response.status >= 400 begin response_hash = MultiJson.load(response.body) rescue MultiJson::DecodeError 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_app_properties(properties, args = {}, options = {}) ⇒ Object
Set a Facebook application’s properties.
21 22 23 24 |
# File 'lib/koala/api/rest_api.rb', line 21 def set_app_properties(properties, args = {}, = {}) raise AuthenticationError.new(nil, nil, "setAppProperties requires an access token") unless @access_token rest_call("admin.setAppProperties", args.merge(:properties => MultiJson.dump(properties)), , "post") end |