mmangino / mogli

Facebook Open Graph Library
http://developers.facebook.com/docs/opengraph
MIT License
308 stars 107 forks source link

send photo #15

Closed rlisowski closed 14 years ago

rlisowski commented 14 years ago

I'm try to send photo to album. I do it this way:

album.photos_create(
  Mogli::Photo.new(
    :source => local_photo_path,
    :message => "message"
  ))

album is a valid Mogli::Album object but when I do this i get error:

The property 'message' is not defined for this Dash.
/home/httpd/html/fox/releases/20101020114522/vendor/gems/hashie-0.4.0/lib/hashie/dash.rb:107:in `assert_property_exists!'
/home/httpd/html/fox/releases/20101020114522/vendor/gems/hashie-0.4.0/lib/hashie/dash.rb:92:in `[]'
/home/httpd/html/fox/releases/20101020114522/vendor/gems/mogli-0.0.15/lib/mogli/model.rb:27:in `post_params'
/home/httpd/html/fox/releases/20101020114522/vendor/gems/mogli-0.0.15/lib/mogli/model.rb:26:in `each'
/home/httpd/html/fox/releases/20101020114522/vendor/gems/mogli-0.0.15/lib/mogli/model.rb:26:in `post_params'
/home/httpd/html/fox/releases/20101020114522/vendor/gems/mogli-0.0.15/lib/mogli/model.rb:82:in `photos_create'

What I do wrong?

I get this error even if do only

album.photos_create(
  Mogli::Photo.new(
    :source => local_photo_path
  ))
deneuxa commented 14 years ago

I have the exact same error....

deneuxa commented 14 years ago

Bypass for now:

require 'curb' def publish_fb_photo(path)
c = Curl::Easy.new('https://graph.facebook.com/me/photos') c.multipart_form_post = true c.http_post( Curl::PostField.content('access_token', current_facebook_user.client.access_token), Curl::PostField.file('source', path)) end

rlisowski commented 14 years ago

I do it with system command:

res = `curl -F 'access_token=#{current_facebook_user.client.access_token}' \
 -F 'source=@file_path.png' \
 -F 'message=Caption for the photo' \
 https://graph.facebook.com/me/photos`

http://developers.facebook.com/docs/reference/api/photo

mmangino commented 14 years ago

I'd be happy to take a patch to do this. You could coordinate with the person on https://github.com/jnunemaker/httparty/issuesearch?state=open&q=multipart#issue/52 who is talking about adding multipart support to HTTParty