Closed rtdp closed 12 years ago
This code used to give me RestClient::BadRequest error sometimes. And this behavior was very random. It took me long to debug that issue which was with :caption part here. As sometimes, values for :caption was more than 255 characters and so request was failing. It took some time to figure out and change above code to use :description rather than :caption. Just posting here so somebody may find helpful, also can fbgraph has something to reflect errors little better way?
I was using the code like as follows -
def broadcast_on_facebook(donation) client = FBGraph::Client.new(:client_id => facebook_account.uid ,:token => facebook_account.access_token) u = client.selection.me.info! client.selection.user(u[:id]).feed.publish!( :message => "I donated for #{donation.cause.name} on mySite. Feels good and satisfied to be helpful to somebody in need.", :name => "Donate Now !!", :link => "#{RETURN_URL_LOCALHOST}?uuid=#{uuid}", :picture => 'https://mysite.net/images/modules/header/logov3-hover.png', :caption => donation.cause.description ) donation.update_attributes(:broadcasted => true) end