So here is an interesting code snippet that works for getting access for a
desktop application. Note: I think you still need to send people to a
browser to get permissions. And I can''t see yet how to make sure that
people grant offline access.
require File.dirname(__FILE__) + ''/../config/environment''
ENV[''FACEBOOK_API_KEY''] =
''d426e210e1253c5cd7d86d6683cef056''
ENV[''FACEBOOK_SECRET_KEY''] = ''SECRET''
session = Facebooker::Session.create(
''d426e210e1253c5cd7d86d6683cef056'',
''SECRET'' )
puts session.auth_token #this makes the call to get auth token
puts "Paste the URL into your web browser and login:"
puts session.login_url + "&auth_token=#{session.auth_token}";
puts "Hit return to continue..."
gets
puts "What are you doing?"
puts "#{session.user.name} #{session.user.status.message}"
puts "Session " + session.inspect
puts "Key " +
session.instance_variable_get("@session_key").to_s;
puts "Expires " +
session.instance_variable_get("@expires").to_s;
puts "User" + session.user.id.to_s
puts "Session Secret " +
session.instance_variable_get("@secret_from_session").to_s;
# Now you could save the session key and expiry to make more calls later.
But only for an hour.
file = Net::HTTP::MultipartPostFile.new(
"test.png",
"",
File.read("/Users/dclements/Desktop/screen0.png")
)
session.user.upload_photo(file,:caption => "just messing around")
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/facebooker-talk/attachments/20090112/ee758025/attachment.html>