Facebook API and Callbacks

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Facebook API and Callbacks

leonsmith
I am trying to create a singleton object in Amber like smalltalk. My
code just returns <FB> which gets defined upon loading the Facebook
Javascript API. The problem seems to be timing. I get an error message
the JSObjectProxy doesn't understand "example", but by the time I
inspect the object its there !

The tag that loads the API is:
        <script src="http://connect.facebook.net/en_US/all.js"></script>
then later in the html I have:
                <script type="text/javascript">
                  loadAmber({
                        files: ['FBook.js'],
                        prefix: 'projects/fbook/js',
                        ready: function() {
                        smalltalk.FBook._example();
                        }});
                </script>

So should I use a callback for when the FB API is finished loading ?
If so, is it possible to put it on the Amber side using a Block ?

Sorry for being dense. I'm slowly getting it but the Amber to JS bit
still has me confused. I have looked at the source for Amber and it
looks like #smalltalk gets defined in some CodeMirror stuff which is
not clear to me.
Reply | Threaded
Open this post in threaded view
|

Re: Facebook API and Callbacks

leonsmith
Turns out debugging FB apps from Javascript is a real pain. It seems
that even if you have your app in "sandbox" mode, you still have to
have a real domain name calling the FB graph API over SSL. I don't
think shared SSL will work, but I have not verified this.

I'll try and write up a little cheat sheet after I get the app
working.

On Feb 8, 9:02 am, leonsmith <[hidden email]> wrote:

> I am trying to create a singleton object in Amber like smalltalk. My
> code just returns <FB> which gets defined upon loading the Facebook
> Javascript API. The problem seems to be timing. I get an error message
> the JSObjectProxy doesn't understand "example", but by the time I
> inspect the object its there !
>
> The tag that loads the API is:
>         <script src="http://connect.facebook.net/en_US/all.js"></script>
> then later in the html I have:
>                 <script type="text/javascript">
>                   loadAmber({
>                         files: ['FBook.js'],
>                         prefix: 'projects/fbook/js',
>                         ready: function() {
>                         smalltalk.FBook._example();
>                         }});
>                 </script>
>
> So should I use a callback for when the FB API is finished loading ?
> If so, is it possible to put it on the Amber side using a Block ?
>
> Sorry for being dense. I'm slowly getting it but the Amber to JS bit
> still has me confused. I have looked at the source for Amber and it
> looks like #smalltalk gets defined in some CodeMirror stuff which is
> not clear to me.