Created
April 19, 2012 09:31
-
-
Save cgallagher/2419949 to your computer and use it in GitHub Desktop.
Pubish a UGC Image via Bookface
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def publish!(fbid, key, shwop=nil, entry=nil) | |
fb_action = Facebookaction.find_by_key(key) | |
access_token = Bookface::Base.client_credentials | |
a_type = fb_action.action_type | |
url = "http://#{Settings.host_url}/actions/#{fb_action.key}" | |
if entry.width > 520 and entry.height > 520 | |
puts "image is big enough for user generated attachment" | |
params = { Settings.facebook.fb_object_ref => url, | |
"image[0][url]" => entry.entry_asset_url, | |
"image[0][user_generated]" => "true", | |
"message" => "#{entry.description}", | |
:access_token => access_token | |
} | |
else | |
puts "image isnt big enough - normal action pushed" | |
params = { Settings.facebook.fb_object_ref => url, | |
:access_token => access_token | |
} | |
end | |
res = Bookface::Graph.request("#{fbid}/#{Settings.facebook.namespace}:#{a_type}", params, :method => :post) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment