简体   繁体   中英

Facebook Post as a image

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM