简体   繁体   English

在Phalcon中添加facebook SDK

[英]Add facebook SDK in Phalcon

I'm trying to load Facebook SDL into my project but at the moment with no success 我正在尝试将Facebook SDL加载到我的项目中,但目前没有成功

here is my bootstrap dispatcher: 这是我的引导调度程序:

$di->set('Facebook', function() use ($config) { 
    return new Facebook(array( 
        'appId' => $config->facebook->appId, 
        'secret' => $config->facebook->secret, 
        'fileUpload' => $config->facebook->fileUpload, 
        'allowSignedRequest' => $config->facebook->allowSignedRequest, )); 
});

the loader looks like this(in code is before dispatcher): 加载程序看起来像这样(代码在调度程序之前):

$loader->registerDirs( array( 
    DIR . $config->application->controllersDir, 
    DIR . $config->application->pluginsDir, 
    DIR . '/app/library', DIR . $config->application->modelsDir, 
    DIR . '/app/facebook', ) 
)->register();

where facebook files were put in /app/facebook, /app/library, /app/library/facebook. 将facebook文件放在/ app / facebook,/ app / library,/ app / library / facebook中的位置。 I tried multiple ways of including the files. 我尝试了多种方法来包含文件。

I called the facebook class like this: $user = $this->Facebook->getUser(); 我这样称呼Facebook类: $user = $this->Facebook->getUser(); in IndexController and error which i received is: Fatal error: Class 'Facebook' not found in /mylongpath/public/index.php on line 142 在IndexController中,我收到的错误是:致命错误:在第142行的/mylongpath/public/index.php中找不到类'Facebook'

I assume the problem is the loader by not sure what and why. 我假设问题出在装载机上,不确定什么以及为什么。 Please help me with this situation. 请帮我解决这种情况。

The rest of project is "INVO" tutorial. 项目的其余部分是“ INVO”教程。

Might be a bad guess, but if you are with invo and based on index.php , your app is one level up related to your public/index.php , making it: 可能是个不好的猜测,但是如果您使用invo并基于index.php ,则您的app将与您的public/index.php ,从而使它升级:

$loader->registerDirs( array( 
    __DIR__ . $config->application->controllersDir, 
    __DIR__ . $config->application->pluginsDir, 
    __DIR__ . $config->application->modelsDir,
    __DIR__ . '/../app/library', 
    __DIR__ . '/../app/facebook') 
)->register();

Make sure to use __DIR__ , not DIR , unless you've set it up as an actual var / cost before. 确保使用__DIR__而不是DIR ,除非之前已将其设置为实际的var / cost。

+ did composer got out of fashion? + 作曲家过时了吗?

"facebook/php-sdk": "@stable"
composer install

https://github.com/geass/Phalcon-Facebook-Library https://github.com/geass/Phalcon-Facebook-Library

i did smt like that , maybe it is what u ar trying to do. 我确实是那样的,也许这就是你想做的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM