Creating Facebook Events with an Image

45 views
Skip to first unread message

ssgrfk

unread,
Jul 26, 2010, 1:24:45 PM7/26/10
to mini_fb
Hey.
Im successfully using Mini FB to create Facebook events from my rails
app. What i want to do now is create those events with a user uploaded
image, or a default image if the user doesnt specify one.
I was able to do this with the old facebook API using Facebooker
using :

fullpath = Rails.public_path + "/images/FBEvent.jpg"
file = File.open(fullpath,"rb")
data = file.read
@image = Net::HTTP::MultipartPostFile.new("Image Name",nil,data)

and then posting the @image after the :params for the Facebook event.

I cant seem to get this working with Mini_FB.. anyone shed some light
on this?

thank you.

Travis Reeder

unread,
Jul 26, 2010, 4:16:30 PM7/26/10
to min...@googlegroups.com
Have you tried MiniFB.post with the :picture options?

Travis


--
You received this message because you are subscribed to the Google Groups "mini_fb" group.
To post to this group, send email to min...@googlegroups.com.
To unsubscribe from this group, send email to mini_fb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mini_fb?hl=en.


ssgrfk

unread,
Jul 27, 2010, 9:48:48 AM7/27/10
to mini_fb
Sorry i should have been more specific.

How can i create the image, to pass as :picture?

What i was using with Facebooker no longer works. ie
Net::HTTP::MultipartPostFile.new("Image Name",nil,data)

thx

Travis Reeder

unread,
Jul 27, 2010, 12:33:05 PM7/27/10
to min...@googlegroups.com
I believe you want to pass in a File object, someone made a patch for this a while back that accepts File objects.


--

jayro

unread,
Aug 11, 2010, 6:17:15 PM8/11/10
to mini_fb
Could i ask what your code looks like for posting an event (minus the
file)? ive tried a hash and json and all i get are errors like this:

can't convert RestClient::Payload::UrlEncoded into String

event_hash = {"name"=>"Tourdate St. Louis MO US", "location"=>"Fubar",
"end_time"=>1281409200000, "description"=>"This is the description of
the event", "start_time"=>1281398400000}

MiniFB.post(current_fanclub.facebook_page_access_token,
current_fanclub.facebook_page_name, event_hash)

MiniFB.post(current_fanclub.facebook_page_access_token,
current_fanclub.facebook_page_name, :params=>event_hash)

MiniFB.post(access_token,
account_id, :type=>'events', :params=>event_hash)

MiniFB.post(access_token,
account_id, :type=>'events', :params=>event_hash.merge(:type=>'events'))


No matter what i do the same error:

TypeError: can't convert RestClient::Payload::UrlEncoded into String
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/openssl/buffering.rb:170:in `<<'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/openssl/buffering.rb:170:in `do_write'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/openssl/buffering.rb:192:in `write'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/net/protocol.rb:177:in `write0'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/net/protocol.rb:153:in `write'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/net/protocol.rb:168:in `writing'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/net/protocol.rb:152:in `write'
from /Library/Ruby/Gems/1.8/gems/right_http_connection-1.2.4/lib/
net_fix.rb:98:in `send_request_with_body'
from /Library/Ruby/Gems/1.8/gems/right_http_connection-1.2.4/lib/
net_fix.rb:83:in `exec'
from /Library/Ruby/Gems/1.8/gems/right_http_connection-1.2.4/lib/
net_fix.rb:144:in `request'
from /Library/Ruby/Gems/1.8/gems/rest-client-1.6.0/lib/restclient/
request.rb:167:in `transmit'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/
ruby/1.8/net/http.rb:543:in `start'
from /Library/Ruby/Gems/1.8/gems/rest-client-1.6.0/lib/restclient/
request.rb:166:in `transmit'
from /Library/Ruby/Gems/1.8/gems/rest-client-1.6.0/lib/restclient/
request.rb:60:in `execute'
from /Library/Ruby/Gems/1.8/gems/rest-client-1.6.0/lib/restclient/
request.rb:31:in `execute'
from /Library/Ruby/Gems/1.8/gems/rest-client-1.6.0/lib/restclient.rb:
72:in `post'
from /Users/jerrod/Sites/network.roadrunnerrecords.com/vendor/plugins/
mini_fb/lib/mini_fb.rb:588:in `fetch'
from /Users/jerrod/Sites/network.roadrunnerrecords.com/vendor/plugins/
mini_fb/lib/mini_fb.rb:537:in `post'

Travis Reeder

unread,
Aug 11, 2010, 8:03:57 PM8/11/10
to min...@googlegroups.com
Try with a different date format, like the ones here: http://www.php.net/manual/en/datetime.formats.compound.php

Travis

Jerrod Blavos

unread,
Aug 11, 2010, 8:56:45 PM8/11/10
to min...@googlegroups.com
no go.

i even tried using the date (copy/paste) from the sample on the facebook dev site here =>
https://graph.facebook.com/331218348435 so i dont think its the date format.

it also seems that doing any .post call raises this error

>> MiniFB.post(access_token, 'me')

TypeError: can't convert RestClient::Payload::UrlEncoded into String

curious.

GET requests work great:

MiniFB.get(current_fanclub.facebook_page_access_token, 'me')
resp={"id":"124624130883738","name":"RecCenter","link":"http:\/\/www.facebook.com\/pages\/RecCenter\/124624130883738","category":"Local_technology_telecommunications_services","fan_count":3}
=> <#Hashie::Mash category="Local_technology_telecommunications_services" fan_count=3 id="124624130883738" link="http://www.facebook.com/pages/RecCenter/124624130883738" name="RecCenter"

Jerrod Blavos

unread,
Aug 11, 2010, 10:37:34 PM8/11/10
to min...@googlegroups.com
and for reference - this works, using the hyper-graph gem ==> http://github.com/chrisdinn/hyper-graph


>> token = facebook_page_access_token
=>"1400842345358094 |1e88b25657af773e5d1cd98-682730385|13043245686971963|f7887S-V4pk5a24566ahKOVDFk."

>>page_id = facebook_page_access_token.split('|').first
=>"1400842345358094"

>>graph = HyperGraph.new( token )
=> #<HyperGraph:0x108c1a698 @access_token="1400842345358094 |1e88b25657af773e5d1cd98-682730385|13043245686971963|f7887S-V4pk5a24566ahKOVDFk.">

>>graph.post("#{page_id}/events", :name=>"dude", :description=>"awesome", :start_time=>'1215929160', :end_time=>'1215929160', :location=>'the phoenix')   
=>{:id=>122527554461466}

i am at a loss for why i cannot post anything to facebook using mini_fb.



On Aug 11, 2010, at 8:03 PM, Travis Reeder wrote:

Travis Reeder

unread,
Aug 12, 2010, 1:42:15 PM8/12/10
to min...@googlegroups.com
Are you able to post simple messages to a wall?  I just tested it with the mini_fb_demo app here: http://github.com/appoxy/mini_fb_demo and it worked fine.  Let me know if you can do basic messages just to see if it's an event thing.

Travis

Jerrod Blavos

unread,
Aug 12, 2010, 1:52:04 PM8/12/10
to min...@googlegroups.com
ill pull down the app and give it a shot and let you know.

thanks!

Jerrod Blavos

unread,
Aug 12, 2010, 2:21:16 PM8/12/10
to min...@googlegroups.com
message successfully posted from the sample app!

I also added an event posting form to the app for testing that you could pull into your sample app - i know posting events is a huge pain and the interwebs helped little -


the date definitely needs to be an epoch date, which you can get from a datetime object by adding .to_i

and the venue information needs to bot be nested - essentially all params need to not be nested in any sort of way.

so my issue above is going to be application specific, now for the fun part - tracking down what it is....

thanks for your help!


On Aug 12, 2010, at 1:42 PM, Travis Reeder wrote:

Jerrod Blavos

unread,
Aug 12, 2010, 2:33:09 PM8/12/10
to min...@googlegroups.com
On Aug 12, 2010, at 1:42 PM, Travis Reeder wrote:

Travis Reeder

unread,
Aug 12, 2010, 2:56:03 PM8/12/10
to min...@googlegroups.com
Cool, I'll pull your changes in.
Reply all
Reply to author
Forward
0 new messages