We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36760
    • 136 Posts
    I've been following along with this website to implement Facebook Connect/Login on a Modx Revo site I'm helping someone with: http://edwardawebb.com/web-development/facebook-login-modx-sites

    Right now I'm stuck getting this error:

    Fatal error: Call to undefined method Facebook::getSession()

    I've read that it could be an outdated PHP Client, though I've downloaded the one from here: https://github.com/facebook/php-sdk/, which I believe is the official place for it.

    My snippets look identical to the ones on the website (only with my application ID's entered in the snippet call), and I'm not sure what else to try.

    If there's a better way to implement this now, I'm open to that as well.

    Thanks for the help. [ed. note: firebot6 last edited this post 14 years, 9 months ago.]
      • 3749
      • 24,544 Posts
      That error suggests that the Facebook class file is not being loaded, or the constructor for that class failed (or is not called before the getSession() call ).

      There should be an "include" statement that pulls in the Facebook class file. If you change "include" to "require" you may see an error message telling you what file it's looking for and where it's looking.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 36760
        • 136 Posts
        That's getting me somewhere. It's trying to read the file from the core/cache/includes/elements folder, instead of reading the path from the root of the server.

        I tried quite a few things to get the root path to show up instead, but none of them worked for me (mostly things from the comments on these pages http://php.net/manual/en/function.require-once.php and http://php.net/manual/en/function.getenv.php).

        The files are located at www.example.com/facebook-connect/facebook.php
        Or /home/server/public_html/facebook-connect/facebook.php

        Here is the full snippet: http://pastebin.com/nd4QYkKQ

        I kept the simple require path that I started with in there (and removed comments to save space).

        You seem to end up helping me quite a bit! I do appreciate it.
          • 3749
          • 24,544 Posts
          I would move the file(s) to core/components/facebook/ and change the line to
           require MODX_CORE_PATH . 'components/facebook/facebook.php';


          Unless there are files that need to be accessed via URL. If that's the case, use MODX_ASSETS_URL.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 36760
            • 136 Posts
            I'm still getting the fatal error:

            Fatal error: Call to undefined method Facebook::getSession() in /home/server/public_html/core/cache/includes/elements/modsnippet/80.include.cache.php on line 33

            Once the website I was following along with is back up, I'm going to try starting over from the beginning again, and see if maybe I didn't make a mistake a long the way. Then I'll report back here.
              • 3749
              • 24,544 Posts
              Try deleting all files in the core/cache directory first and calling the snippet with the ID of 80 uncached.

              [[!SnippetName]]
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 36760
                • 136 Posts
                I finally found something. It seems getSession is no longer supported in the new SDK versions (https://developers.facebook.com/blog/post/503).

                I'll see if I can get the snippets updated. I'll come back once I've messed with it some more.
                  • 36760
                  • 136 Posts
                  Changing all instance of $session to $user seems to have done the trick. Now I'm just having issues passing the information from Facebook onto Modx.

                  Once I figure that out, I'll post my full code here.
                    • 36760
                    • 136 Posts
                    I'm going to cave and ask again. I'm in a little over my head.

                    In the same snippet: http://pastebin.com/SUUa8VYX

                    Most of the user data is being passed into the Remote Fields tab. Is there any way to have it fill in the main profile boxes, like it looks like it should from the snippet? I feel like I've asked about this before, but I can't find the thread again.

                    I will likely pull more information from Facebook eventually, but figured I would start with what's in there now.
                      • 3749
                      • 24,544 Posts
                      I'm not sure what you're asking, since I've never used the snippet, but if you want things filled in and the snippet is at the top of the page, you can put placeholders on the page:

                      [[+home_town]]


                      And set them in the code:
                      $modx->setPlaceholder('home_town', $me['hometown']);
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting