fb_connect_async_js code differ from facebook docs

16 views
Skip to first unread message

kreigne

unread,
Nov 10, 2011, 6:30:38 PM11/10/11
to facebooker
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.

Mike Mangino

unread,
Nov 11, 2011, 9:10:35 AM11/11/11
to faceb...@googlegroups.com
It's possible that Facebook changed the way they want the async js used. I'm happy to take patches for that.

Mike

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

--
Mike Mangino
http://www.elevatedrails.com

Reply all
Reply to author
Forward
0 new messages