Hi Mike and all,
I am having some problems using fb_connect_async_js and some jQuery
plugins that calls the facebook javascript SDK (The error I get is
that the FB object does not exists when the jQuery plugin tries to
call it), so I was taking a look at the asynchronous loading and
initialization code at:
https://developers.facebook.com/docs/reference/javascript/
And I realized it's a bit different than the one returned by the
fb_connect_async_js method...
The code returned from fb_connect_async_js should be the same as the
one in the facebook docs?
2 - Is there any chance that this differences are causing my problem?
PS: In the meantime, I created a facebook_connect_sync_js method for
loading the SDK synchronously, it's working, but I know it's not the
best recommended way to use it, my method code is below:
<code>
def fb_connect_sync_js(app_id=Facebooker2.app_id,options={},&proc)
opts = Hash.new.merge!(options)
cookie = opts[:cookie].nil? ? true : opts[:cookie]
status = opts[:status].nil? ? true : opts[:status]
xfbml = opts[:xfbml].nil? ? true : opts[:xfbml]
oauth2 = Facebooker2.oauth2 ? true : false
channel_url = opts[:channel_url]
lang = opts[:locale] || 'en_US'
extra_js = capture(&proc) if block_given?
js = <<-JAVASCRIPT
<div id="fb-root"></div>
<script src="
http://connect.facebook.net/#{lang}/all.js"></script>
<script>
FB.init({
appId : '#{app_id}',
status : #{status}, // check login status
cookie : #{cookie}, // enable cookies to allow the server to
access the session
#{"channelUrl : '#{channel_url}', // add channelURL to avoid IE
redirect problems" unless channel_url.blank?}
#{"oauth : true," if oauth2}
xfbml : #{xfbml} // parse XFBML
});
#{extra_js}
</script>
JAVASCRIPT
escaped_js = fb_html_safe(js)
if block_given?
concat(escaped_js)
#return the empty string, since concat returns the buffer and we
don't want double output
# from klochner
""
else
escaped_js
end
end
</code>
Thanks in advance.