diff --git a/app/controllers/facebook_controller.rb b/app/controllers/facebook_controller.rb index 3abc91fe..551587e5 100644 --- a/app/controllers/facebook_controller.rb +++ b/app/controllers/facebook_controller.rb @@ -38,6 +38,26 @@ class FacebookController< ApplicationController end end + def get_feed + fb = current_user.facebook rescue nil + if fb + @url = "#{@@facebook_server}/get_feed?identifier=" + current_user.facebook.fb_identifier + uri = URI.parse(@url) + http = Net::HTTP.new(uri.host, uri.port) + request = Net::HTTP::Get.new(uri.request_uri) + response = http.request(request) + feed = response.body + feed = JSON.parse(feed) + output = Array.new + feed.each do |f| + output << {"story"=>f['raw_attributes']['story']} + end + render :json=>{"success"=>true,"count"=>feed.count,"feed"=>output}.to_json + else + render :json=>{"success"=>false,"message"=>"User is not connected to facebook."}.to_json + end + end + def disconnect user_fb = current_user.facebook if user_fb diff --git a/config/routes.rb b/config/routes.rb index 69430665..d25df380 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -332,6 +332,7 @@ Orbit::Application.routes.draw do match "/facebook/register_fb" => "facebook#register_fb" match "/facebook/get_friends" => "facebook#get_friends" + match "/facebook/get_feed" => "facebook#get_feed" match "/facebook/disconnect" => "facebook#disconnect" match "/facebook/server" => "facebook#server_redirect" match "/facebook/profile_import" => "facebook#profile_import"