Facebook SDK v4 for PHP Minimal Example

前端 未结 8 869
夕颜
夕颜 2020-12-02 14:44

I\'m trying to get the minimal example

using Facebook\\FacebookSession;

FacebookSession::setDefaultApplication(\'YOUR_APP_ID\',\'YOUR_APP_SECRET\');

// Use         


        
相关标签:
8条回答
  • 2020-12-02 15:43

    I solved it. Just use following line at the top of your script:

    define('FACEBOOK_SDK_V4_SRC_DIR', __DIR__ . '/facebook-php-sdk-v4/src/Facebook/');
    

    and you are done.

    0 讨论(0)
  • 2020-12-02 15:45

    I think you need to change this line:

    using Facebook\FacebookSession;
    

    to

    use Facebook\FacebookSession;
    

    to use a namespace in php the keyword is use more on php using namespaces

    Update:

    using namespaces does not automatically include the script, you either need to include the path in your autoload (if you have one) or simply:

    include 'path/to/FacebookSession.php';
    

    Update2: first, please read the php namespaces in the manual, second, no, if it is already included in the original class then you don't. or if it is adhering to psr-* then you can use some autoloader or use spl_autoload_register

    0 讨论(0)
提交回复
热议问题