使用Koala将图片发布到Facebook群组

时间:2015-02-05 12:27:44

标签: ruby-on-rails ruby facebook facebook-graph-api koala

我有Ruby On Rails应用程序并使用gem koala。我正在使用方法

graph.put_connections(owner_id, "feed", { 
    message: generate_message,
    link: generate_link, 
    object_id: id_image 
}, api_version: "v2.0")

我需要在论坛中发布带有图片的帖子。目前我在相册中上传了一张照片。在发布时,我将上传图像的ID附加到帖子,但没有放置图片。

只是一条消息。问题是什么?是否可以发布内部图片?

1 个答案:

答案 0 :(得分:0)

请参考此 -

page_image = @newgraph.get_connections(params[:id],"tabs/app_14548156*****434",{:custom_name =>params['custom_name'],  :custom_image_url =>["custom_image_url"]})
@user.update_attributes(:facebook_store_url => page_image["id".to_i]["link"],:facebook_store_tab_name => page_image["id".to_i]["name"], :fbimage => "http://www.yyy.com/thought_images/thumb0/232_images.jpg")

我的代码是 -

def facebook_store_page
  #@graph  = Koala::Facebook::API.new(current_user)

  if params['user_id']
    @user = User.find params[:user_id]
    @user.update_attributes(:facebook_page_id =>  params[:id], :facebook_page_token =>params['pagetoken'])  
    @newgraph=Koala::Facebook::API.new(params[:pagetoken])
    @PagecustomTab=@newgraph.put_connections("me","tabs",  {:app_id => '14548156*****434'})
        @pageid   = current_user.facebook_page_id
        page_image = @newgraph.get_connections(params[:id],"tabs/app_14548156*****434",{:custom_name =>params['custom_name'],  :custom_image_url =>["custom_image_url"]})
        @user.update_attributes(:facebook_store_url => page_image["id".to_i]["link"],:facebook_store_tab_name => page_image["id".to_i]["name"], :fbimage => "http://www.yyy.com/thought_images/thumb0/232_images.jpg")
    respond_to do |format|

      format.json { render json: true}
    end

  else

  end