0

I wants to post a post on Facebook as a Image not a text (and not as album too) , And I'm using below code :

def facebook_page
@page ||= Mogli::Page.new(:id => facebook_page_id, :client => Mogli::Client.new(facebook_page_token))
end

def post_to_facebook_page()
    post_params = {
    :message     => "message,"
    :link        => "url.jpeg"
    :name        => "name",
    :description => "description",
    :picture     => "picture_url"
   } 
    facebook_page.feed_create(Mogli::Post.new(post_params))
    rescue Mogli::Client::OAuthException, Mogli::Client::HTTPException => e
   Rails.logger.error("Unable to post to Facebook page #{facebook_page_id} due to #{e.message} on #{Time.now}")
end

But it is not posting as I expected : Here is the output: http://www.facebook.com/profile.php?id=100004124073785 all posts are as a text and

I expected :

http://www.facebook.com/bigjoneschicago?fref=ts find first post "Handmade pasta new on the menu tonight" , Could any one help me on this.

Neelesh
  • 1,458
  • 2
  • 13
  • 20

1 Answers1

1

You don’t want to post a link, but a photo instead: https://developers.facebook.com/docs/reference/api/user/#photos

Edit in response to comment:

Using source parameter requires data formated like an actual HTTP file upload. If you want to upload a picture using it’s publicly reachable URL, use parameter url instead.

And yes, if you don’t specify an album to upload to explicitly, the photo will go to an album named after your app. You can upload to a specific album instead, but that requires permission user_photos.

CBroe
  • 91,630
  • 14
  • 92
  • 150
  • I'm using this {:source=>"https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-ash3/c67.0.403.403/p403x403/12172_10151311056527497_1467682994_n.jpg", :message=>"111message"} @page.photos_create(Mogli::Post.new(post_params)) and giving me error Mogli::Client::OAuthException: (#324) Requires upload file also I think It will create a untitled albums. :( By the way thank you so much... – Neelesh Dec 10 '12 at 08:57
  • Warning: property url doesn't exist for class Mogli::Post.. Also I don't want to create an album, simply like when you create a post you have an options in facebook "status","photo" ,"Place" so I just wanted to use Photo action. when you use this it will not collapse all post in once. But If I'm creating a photos as text , they getting shrink in one post as happens normally when you uplaod photos... :( – Neelesh Dec 10 '12 at 09:40
  • I have done by this : page = Mogli::Page.new(:id => facebook_page_id, :client => Mogli::Client.new(facebook_page_token)) albums = page.albums album = albums.map{|album| album if album.name == "Timeline Photos"}.compact.first facebook_page.client.post("#{album.id}/photos", nil, {:url =>post_params[:picture] ,:name =>"#{post_params[:message]} : #{post_params[:description]}"}) By the way thank you so much @CBroe – Neelesh Dec 10 '12 at 15:10