facebook feed for desktop

This commit is contained in:
Harry Bomrah 2013-12-26 19:03:04 +08:00 committed by saurabhbhatia
parent 6c3f4bff8c
commit 6f44554822
2 changed files with 21 additions and 0 deletions

View File

@ -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

View File

@ -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"